8000 Fix case of Cookie.HTTP_ONLY_ATTR · apache/httpcomponents-client@9bae302 · GitHub
[go: up one dir, main page]

S 8000 kip to content

Commit 9bae302

Browse files
fp7ok2c
authored andcommitted
Fix case of Cookie.HTTP_ONLY_ATTR
1 parent 0ba6102 commit 9bae302

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

httpclient5/src/main/java/org/apache/hc/client5/http/cookie/Cookie.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public interface Cookie {
4545
String MAX_AGE_ATTR = "max-age";
4646
String SECURE_ATTR = "secure";
4747
String EXPIRES_ATTR = "expires";
48-
String HTTP_ONLY_ATTR = "httpOnly";
48+
String HTTP_ONLY_ATTR = "httponly";
4949

5050
/**
5151
* @since 5.0

httpclient5/src/test/java/org/apache/hc/client5/http/impl/cookie/TestRFC6265CookieSpec.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,19 @@ void testParseCookieWithAttributes3() throws Exception {
202202
Assertions.assertEquals("", cookie.getAttribute("p1"));
203203
}
204204

205+
@Test
206+
void testParseCookieWithHttpOnly() throws Exception {
207+
final RFC6265CookieSpec cookiespec = new RFC6265CookieSpec();
208+
209+
final Header header = new BasicHeader("Set-Cookie", "name = value ; HttpOnly");
210+
final CookieOrigin origin = new CookieOrigin("host", 80, "/path/", true);
211+
final List<Cookie> cookies = cookiespec.parse(header, origin);
212+
213+
Assertions.assertEquals(1, cookies.size());
214+
final Cookie cookie = cookies.get(0);
215+
Assertions.assertTrue(cookie.containsAttribute(Cookie.HTTP_ONLY_ATTR));
216+
}
217+
205218
@Test
206219
void testValidateCookieBasics() throws Exception {
207220
final CommonCookieAttributeHandler h1 = Mockito.mock(CommonCookieAttributeHandler.class);

0 commit comments

Comments
 (0)
0