do not break if we do not have a host name for cookie domain
This commit is contained in:
parent
9baa804bc2
commit
54ce2c8074
1 changed files with 5 additions and 2 deletions
|
@ -137,7 +137,7 @@ public class OutgoingContextHandler implements HttpHandler {
|
|||
PercentEncoder percentEncoder = PercentEncoders.getCookieEncoder(StandardCharsets.ISO_8859_1);
|
||||
DefaultCookie cookie = new DefaultCookie(sessionCookieName, percentEncoder.encode(cookieValue));
|
||||
String domain = extractDomain(host);
|
||||
if ("localhost".equals(domain)) {
|
||||
if (domain == null || "localhost".equals(domain)) {
|
||||
logger.log(Level.WARNING, "localhost not set as a cookie domain");
|
||||
} else {
|
||||
cookie.setDomain('.' + domain);
|
||||
|
@ -153,7 +153,7 @@ public class OutgoingContextHandler implements HttpHandler {
|
|||
private Cookie createEmptyCookie(String host, String path) {
|
||||
DefaultCookie cookie = new DefaultCookie(sessionCookieName);
|
||||
String domain = extractDomain(host);
|
||||
if ("localhost".equals(domain)) {
|
||||
if (domain == null || "localhost".equals(domain)) {
|
||||
logger.log(Level.WARNING, "localhost not set as a cookie domain");
|
||||
} else {
|
||||
cookie.setDomain('.' + domain);
|
||||
|
@ -168,6 +168,9 @@ public class OutgoingContextHandler implements HttpHandler {
|
|||
}
|
||||
|
||||
private static String extractDomain(String fqdn) {
|
||||
if (fqdn == null) {
|
||||
return null;
|
||||
}
|
||||
if ("localhost".equals(fqdn)) {
|
||||
return fqdn;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue