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.setCharAt(buf.length() - 1, (char) HttpConstants.DOUBLE_QUOTE);
|
||||||
buf.append((char) HttpConstants.SEMICOLON);
|
buf.append((char) HttpConstants.SEMICOLON);
|
||||||
|
buf.append((char) HttpConstants.SP);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,7 @@ final class CookieEncoderUtil {
|
|||||||
|
|
||||||
static String stripTrailingSeparator(StringBuilder buf) {
|
static String stripTrailingSeparator(StringBuilder buf) {
|
||||||
if (buf.length() > 0) {
|
if (buf.length() > 0) {
|
||||||
buf.setLength(buf.length() - 1);
|
buf.setLength(buf.length() - 2);
|
||||||
}
|
}
|
||||||
return buf.toString();
|
return buf.toString();
|
||||||
}
|
}
|
||||||
@ -51,6 +51,7 @@ final class CookieEncoderUtil {
|
|||||||
sb.append((char) HttpConstants.EQUALS);
|
sb.append((char) HttpConstants.EQUALS);
|
||||||
sb.append(val);
|
sb.append(val);
|
||||||
sb.append((char) HttpConstants.SEMICOLON);
|
sb.append((char) HttpConstants.SEMICOLON);
|
||||||
|
sb.append((char) HttpConstants.SP);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void addQuoted(StringBuilder sb, String name, String val) {
|
static void addQuoted(StringBuilder sb, String name, String val) {
|
||||||
@ -64,6 +65,7 @@ final class CookieEncoderUtil {
|
|||||||
sb.append(val.replace("\\", "\\\\").replace("\"", "\\\""));
|
sb.append(val.replace("\\", "\\\\").replace("\"", "\\\""));
|
||||||
sb.append((char) HttpConstants.DOUBLE_QUOTE);
|
sb.append((char) HttpConstants.DOUBLE_QUOTE);
|
||||||
sb.append((char) HttpConstants.SEMICOLON);
|
sb.append((char) HttpConstants.SEMICOLON);
|
||||||
|
sb.append((char) HttpConstants.SP);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void add(StringBuilder sb, String name, long val) {
|
static void add(StringBuilder sb, String name, long val) {
|
||||||
@ -71,6 +73,7 @@ final class CookieEncoderUtil {
|
|||||||
sb.append((char) HttpConstants.EQUALS);
|
sb.append((char) HttpConstants.EQUALS);
|
||||||
sb.append(val);
|
sb.append(val);
|
||||||
sb.append((char) HttpConstants.SEMICOLON);
|
sb.append((char) HttpConstants.SEMICOLON);
|
||||||
|
sb.append((char) HttpConstants.SP);
|
||||||
}
|
}
|
||||||
|
|
||||||
private CookieEncoderUtil() {
|
private CookieEncoderUtil() {
|
||||||
|
@ -83,10 +83,12 @@ public final class ServerCookieEncoder {
|
|||||||
if (cookie.isSecure()) {
|
if (cookie.isSecure()) {
|
||||||
buf.append(CookieHeaderNames.SECURE);
|
buf.append(CookieHeaderNames.SECURE);
|
||||||
buf.append((char) HttpConstants.SEMICOLON);
|
buf.append((char) HttpConstants.SEMICOLON);
|
||||||
|
buf.append((char) HttpConstants.SP);
|
||||||
}
|
}
|
||||||
if (cookie.isHttpOnly()) {
|
if (cookie.isHttpOnly()) {
|
||||||
buf.append(CookieHeaderNames.HTTPONLY);
|
buf.append(CookieHeaderNames.HTTPONLY);
|
||||||
buf.append((char) HttpConstants.SEMICOLON);
|
buf.append((char) HttpConstants.SEMICOLON);
|
||||||
|
buf.append((char) HttpConstants.SP);
|
||||||
}
|
}
|
||||||
if (cookie.getVersion() >= 1) {
|
if (cookie.getVersion() >= 1) {
|
||||||
if (cookie.getComment() != null) {
|
if (cookie.getComment() != null) {
|
||||||
@ -109,10 +111,12 @@ public final class ServerCookieEncoder {
|
|||||||
}
|
}
|
||||||
buf.setCharAt(buf.length() - 1, (char) HttpConstants.DOUBLE_QUOTE);
|
buf.setCharAt(buf.length() - 1, (char) HttpConstants.DOUBLE_QUOTE);
|
||||||
buf.append((char) HttpConstants.SEMICOLON);
|
buf.append((char) HttpConstants.SEMICOLON);
|
||||||
|
buf.append((char) HttpConstants.SP);
|
||||||
}
|
}
|
||||||
if (cookie.isDiscard()) {
|
if (cookie.isDiscard()) {
|
||||||
buf.append(CookieHeaderNames.DISCARD);
|
buf.append(CookieHeaderNames.DISCARD);
|
||||||
buf.append((char) HttpConstants.SEMICOLON);
|
buf.append((char) HttpConstants.SEMICOLON);
|
||||||
|
buf.append((char) HttpConstants.SP);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user