Skip to content

Commit b0da83f

Browse files
author
Yegor Bugayenko
committed
#375 semi-colon to end each cookie line in Set-Cookie
1 parent e88d65a commit b0da83f

File tree

4 files changed

+9
-11
lines changed

4 files changed

+9
-11
lines changed

src/main/java/org/takes/rs/RsWithCookie.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -147,9 +147,9 @@ private static String make(final String previous, final CharSequence name,
147147
if (!previous.isEmpty()) {
148148
text.append(String.format("%s,", previous));
149149
}
150-
text.append(String.format("%s=%s", name, value));
150+
text.append(String.format("%s=%s;", name, value));
151151
for (final CharSequence attr : attrs) {
152-
text.append(';').append(attr);
152+
text.append(attr).append(';');
153153
}
154154
return text.toString();
155155
}

src/test/java/org/takes/facets/flash/TkFlashTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public void removesFlashCookie() throws IOException {
5454
"Cookie: RsFlash=Hello!"
5555
)
5656
).head(),
57-
Matchers.hasItem("Set-Cookie: RsFlash=")
57+
Matchers.hasItem("Set-Cookie: RsFlash=;")
5858
);
5959
}
6060
}

src/test/java/org/takes/facets/ret/TkReturnTest.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public void redirectsAndRemovesCookie() throws IOException {
5656
new RqWithHeader(
5757
new RqFake(),
5858
String.format(
59-
"Cookie: RsReturn=%s",
59+
"Cookie: RsReturn=%s;",
6060
URLEncoder.encode(
6161
destination,
6262
Charset.defaultCharset().name()
@@ -67,7 +67,7 @@ public void redirectsAndRemovesCookie() throws IOException {
6767
Matchers.contains(
6868
"HTTP/1.1 303 See Other",
6969
String.format("Location: %s", destination),
70-
"Set-Cookie: RsReturn="
70+
"Set-Cookie: RsReturn=;"
7171
)
7272
);
7373
}

src/test/java/org/takes/rs/RsWithCookieTest.java

+4-6
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public void addsCookieToResponse() throws IOException {
5454
Matchers.equalTo(
5555
Joiner.on("\r\n").join(
5656
"HTTP/1.1 200 OK",
57-
"Set-Cookie: foo=works?;Path=/",
57+
"Set-Cookie: foo=works?;Path=/;",
5858
"",
5959
""
6060
)
@@ -83,7 +83,7 @@ public void addsMultipleCookies() throws IOException {
8383
Joiner.on("\r\n").join(
8484
"HTTP/1.1 200 OK",
8585
// @checkstyle LineLengthCheck (1 line)
86-
"Set-Cookie: foo=works?;Path=/,bar=worksToo?;Path=/2nd/path/",
86+
"Set-Cookie: foo=works?;Path=/;,bar=worksToo?;Path=/2nd/path/;",
8787
"",
8888
""
8989
)
@@ -93,19 +93,17 @@ public void addsMultipleCookies() throws IOException {
9393

9494
/**
9595
* RsWithCookie can reject invalid cookie name.
96-
* @throws IOException If some problem inside
9796
*/
9897
@Test(expected = IllegalArgumentException.class)
99-
public void rejectsInvalidName() throws IOException {
98+
public void rejectsInvalidName() {
10099
new RsWithCookie(new RsEmpty(), "f oo", "works");
101100
}
102101

103102
/**
104103
* RsWithCookie can reject invalid cookie value.
105-
* @throws IOException If some problem inside
106104
*/
107105
@Test(expected = IllegalArgumentException.class)
108-
public void rejectsInvalidValue() throws IOException {
106+
public void rejectsInvalidValue() {
109107
new RsWithCookie(new RsEmpty(), "bar", "wo\"rks");
110108
}
111109
}

0 commit comments

Comments
 (0)