Correctly format cookies. This fix some bug which lead to expiring of cookies to not work. See #426
This commit is contained in:
parent
8595d85e4a
commit
ae2906de1e
@ -109,6 +109,7 @@ public final class ClientCookieEncoder {
|
||||
}
|
||||
buf.setCharAt(buf.length() - 1, (char) HttpConstants.DOUBLE_QUOTE);
|
||||
buf.append((char) HttpConstants.SEMICOLON);
|
||||
buf.append((char) HttpConstants.SP);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ final class CookieEncoderUtil {
|
||||
|
||||
static String stripTrailingSeparator(StringBuilder buf) {
|
||||
if (buf.length() > 0) {
|
||||
buf.setLength(buf.length() - 1);
|
||||
buf.setLength(buf.length() - 2);
|
||||
}
|
||||
return buf.toString();
|
||||
}
|
||||
@ -51,6 +51,7 @@ final class CookieEncoderUtil {
|
||||
sb.append((char) HttpConstants.EQUALS);
|
||||
sb.append(val);
|
||||
sb.append((char) HttpConstants.SEMICOLON);
|
||||
sb.append((char) HttpConstants.SP);
|
||||
}
|
||||
|
||||
static void addQuoted(StringBuilder sb, String name, String val) {
|
||||
@ -64,6 +65,7 @@ final class CookieEncoderUtil {
|
||||
sb.append(val.replace("\\", "\\\\").replace("\"", "\\\""));
|
||||
sb.append((char) HttpConstants.DOUBLE_QUOTE);
|
||||
sb.append((char) HttpConstants.SEMICOLON);
|
||||
sb.append((char) HttpConstants.SP);
|
||||
}
|
||||
|
||||
static void add(StringBuilder sb, String name, long val) {
|
||||
@ -71,6 +73,7 @@ final class CookieEncoderUtil {
|
||||
sb.append((char) HttpConstants.EQUALS);
|
||||
sb.append(val);
|
||||
sb.append((char) HttpConstants.SEMICOLON);
|
||||
sb.append((char) HttpConstants.SP);
|
||||
}
|
||||
|
||||
private CookieEncoderUtil() {
|
||||
|
@ -83,10 +83,12 @@ public final class ServerCookieEncoder {
|
||||
if (cookie.isSecure()) {
|
||||
buf.append(CookieHeaderNames.SECURE);
|
||||
buf.append((char) HttpConstants.SEMICOLON);
|
||||
buf.append((char) HttpConstants.SP);
|
||||
}
|
||||
if (cookie.isHttpOnly()) {
|
||||
buf.append(CookieHeaderNames.HTTPONLY);
|
||||
buf.append((char) HttpConstants.SEMICOLON);
|
||||
buf.append((char) HttpConstants.SP);
|
||||
}
|
||||
if (cookie.getVersion() >= 1) {
|
||||
if (cookie.getComment() != null) {
|
||||
@ -109,10 +111,12 @@ public final class ServerCookieEncoder {
|
||||
}
|
||||
buf.setCharAt(buf.length() - 1, (char) HttpConstants.DOUBLE_QUOTE);
|
||||
buf.append((char) HttpConstants.SEMICOLON);
|
||||
buf.append((char) HttpConstants.SP);
|
||||
}
|
||||
if (cookie.isDiscard()) {
|
||||
buf.append(CookieHeaderNames.DISCARD);
|
||||
buf.append((char) HttpConstants.SEMICOLON);
|
||||
buf.append((char) HttpConstants.SP);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user