File tree 5 files changed +18
-18
lines changed
main/java/org/springframework/mock/web
test/java/org/springframework
spring-web/src/test/java/org/springframework/mock/web/test
5 files changed +18
-18
lines changed Original file line number Diff line number Diff line change @@ -328,25 +328,25 @@ private String getCookieHeader(Cookie cookie) {
328
328
StringBuilder buf = new StringBuilder ();
329
329
buf .append (cookie .getName ()).append ('=' ).append (cookie .getValue () == null ? "" : cookie .getValue ());
330
330
if (StringUtils .hasText (cookie .getPath ())) {
331
- buf .append (";Path=" ).append (cookie .getPath ());
331
+ buf .append ("; Path=" ).append (cookie .getPath ());
332
332
}
333
333
if (StringUtils .hasText (cookie .getDomain ())) {
334
- buf .append (";Domain=" ).append (cookie .getDomain ());
334
+ buf .append ("; Domain=" ).append (cookie .getDomain ());
335
335
}
336
336
int maxAge = cookie .getMaxAge ();
337
337
if (maxAge >= 0 ) {
338
- buf .append (";Max-Age=" ).append (maxAge );
339
- buf .append (";Expires=" );
338
+ buf .append ("; Max-Age=" ).append (maxAge );
339
+ buf .append ("; Expires=" );
340
340
HttpHeaders headers = new HttpHeaders ();
341
341
headers .setExpires (maxAge > 0 ? System .currentTimeMillis () + 1000L * maxAge : 0 );
342
342
buf .append (headers .getFirst (HttpHeaders .EXPIRES ));
343
343
}
344
344
345
345
if (cookie .getSecure ()) {
346
- buf .append (";Secure" );
346
+ buf .append ("; Secure" );
347
347
}
348
348
if (cookie .isHttpOnly ()) {
349
- buf .append (";HttpOnly" );
349
+ buf .append ("; HttpOnly" );
350
350
}
351
351
return buf .toString ();
352
352
}
Original file line number Diff line number Diff line change @@ -168,9 +168,9 @@ public void cookies() {
168
168
169
169
response .addCookie (cookie );
170
170
171
- assertEquals ("foo=bar;Path=/path;Domain=example.com;" +
172
- "Max-Age=0;Expires=Thu, 01 Jan 1970 00:00:00 GMT;" +
173
- "Secure;HttpOnly" , response .getHeader (HttpHeaders .SET_COOKIE ));
171
+ assertEquals ("foo=bar; Path=/path; Domain=example.com; " +
172
+ "Max-Age=0; Expires=Thu, 01 Jan 1970 00:00:00 GMT; " +
173
+ "Secure; HttpOnly" , response .getHeader (HttpHeaders .SET_COOKIE ));
174
174
}
175
175
176
176
@ Test
Original file line number Diff line number Diff line change @@ -116,8 +116,8 @@ public void buildResponseHeaders() throws Exception {
116
116
assertThat (header .getValue (), equalTo ("value" ));
117
117
header = responseHeaders .get (2 );
118
118
assertThat (header .getName (), equalTo ("Set-Cookie" ));
119
- assertThat (header .getValue (), startsWith ("cookieA=valueA;Path=/path;Domain=domain;Max-Age=1800;Expires=" ));
120
- assertThat (header .getValue (), endsWith (";Secure;HttpOnly" ));
119
+ assertThat (header .getValue (), startsWith ("cookieA=valueA; Path=/path; Domain=domain; Max-Age=1800; Expires=" ));
120
+ assertThat (header .getValue (), endsWith ("; Secure; HttpOnly" ));
121
121
}
122
122
123
123
// SPR-14169
Original file line number Diff line number Diff line change @@ -120,7 +120,7 @@ public void printResponse() throws Exception {
120
120
assertEquals (2 , cookieValues .size ());
121
121
assertEquals ("cookie=cookieValue" , cookieValues .get (0 ));
122
122
assertTrue ("Actual: " + cookieValues .get (1 ), cookieValues .get (1 ).startsWith (
123
- "enigma=42;Path=/crumbs;Domain=.example.com;Max-Age=1234;Expires=" ));
123
+ "enigma=42; Path=/crumbs; Domain=.example.com; Max-Age=1234; Expires=" ));
124
124
125
125
HttpHeaders headers = new HttpHeaders ();
126
126
headers .set ("header" , "headerValue" );
Original file line number Diff line number Diff line change @@ -328,25 +328,25 @@ private String getCookieHeader(Cookie cookie) {
328
328
StringBuilder buf = new StringBuilder ();
329
329
buf .append (cookie .getName ()).append ('=' ).append (cookie .getValue () == null ? "" : cookie .getValue ());
330
330
if (StringUtils .hasText (cookie .getPath ())) {
331
- buf .append (";Path=" ).append (cookie .getPath ());
331
+ buf .append ("; Path=" ).append (cookie .getPath ());
332
332
}
333
333
if (StringUtils .hasText (cookie .getDomain ())) {
334
- buf .append (";Domain=" ).append (cookie .getDomain ());
334
+ buf .append ("; Domain=" ).append (cookie .getDomain ());
335
335
}
336
336
int maxAge = cookie .getMaxAge ();
337
337
if (maxAge >= 0 ) {
338
- buf .append (";Max-Age=" ).append (maxAge );
339
- buf .append (";Expires=" );
338
+ buf .append ("; Max-Age=" ).append (maxAge );
339
+ buf .append ("; Expires=" );
340
340
HttpHeaders headers = new HttpHeaders ();
341
341
headers .setExpires (maxAge > 0 ? System .currentTimeMillis () + 1000L * maxAge : 0 );
342
342
buf .append (headers .getFirst (HttpHeaders .EXPIRES ));
343
343
}
344
344
345
345
if (cookie .getSecure ()) {
346
- buf .append (";Secure" );
346
+ buf .append ("; Secure" );
347
347
}
348
348
if (cookie .isHttpOnly ()) {
349
- buf .append (";HttpOnly" );
349
+ buf .append ("; HttpOnly" );
350
350
}
351
351
return buf .toString ();
352
352
}
You can’t perform that action at this time.
0 commit comments