Add space before cookie attributes

According to RFC-6265 that there should be a space between the ; and
the attribute name, i.e. the header should be something like
name=value; Domain=localhost; HttpOnly rather than
name=value;Domain=localhost;HttpOnly

Issue: SPR-15225
This commit is contained in:
Rossen Stoyanchev
2017-04-25 16:07:25 -04:00
parent abe3cfd8de
commit 6e71828a35
5 changed files with 18 additions and 18 deletions

View File

@@ -168,9 +168,9 @@ public class MockHttpServletResponseTests {
response.addCookie(cookie);
assertEquals("foo=bar;Path=/path;Domain=example.com;" +
"Max-Age=0;Expires=Thu, 01 Jan 1970 00:00:00 GMT;" +
"Secure;HttpOnly", response.getHeader(HttpHeaders.SET_COOKIE));
assertEquals("foo=bar; Path=/path; Domain=example.com; " +
"Max-Age=0; Expires=Thu, 01 Jan 1970 00:00:00 GMT; " +
"Secure; HttpOnly", response.getHeader(HttpHeaders.SET_COOKIE));
}
@Test

View File

@@ -116,8 +116,8 @@ public class MockWebResponseBuilderTests {
assertThat(header.getValue(), equalTo("value"));
header = responseHeaders.get(2);
assertThat(header.getName(), equalTo("Set-Cookie"));
assertThat(header.getValue(), startsWith("cookieA=valueA;Path=/path;Domain=domain;Max-Age=1800;Expires="));
assertThat(header.getValue(), endsWith(";Secure;HttpOnly"));
assertThat(header.getValue(), startsWith("cookieA=valueA; Path=/path; Domain=domain; Max-Age=1800; Expires="));
assertThat(header.getValue(), endsWith("; Secure; HttpOnly"));
}
// SPR-14169

View File

@@ -120,7 +120,7 @@ public class PrintingResultHandlerTests {
assertEquals(2, cookieValues.size());
assertEquals("cookie=cookieValue", cookieValues.get(0));
assertTrue("Actual: " + cookieValues.get(1), cookieValues.get(1).startsWith(
"enigma=42;Path=/crumbs;Domain=.example.com;Max-Age=1234;Expires="));
"enigma=42; Path=/crumbs; Domain=.example.com; Max-Age=1234; Expires="));
HttpHeaders headers = new HttpHeaders();
headers.set("header", "headerValue");