Philippe Mouawad created HTTPCLIENT-1706:
--------------------------------------------
Summary: Domain starting with "." in a cookie makes
CookieSpec#match fails for subdomain
Key: HTTPCLIENT-1706
URL: https://issues.apache.org/jira/browse/HTTPCLIENT-1706
Project: HttpComponents HttpClient
Issue Type: Bug
Components: HttpClient
Affects Versions: 4.5.1
Reporter: Philippe Mouawad
Following:
http://mail-archives.apache.org/mod_mbox/hc-httpclient-users/201512.mbox/%3CCAH9fUpYn6BDFUMA6qq-q4ioFsSQvd%2BFrLJCiSJXaAxnw1ZsBtg%40mail.gmail.com%3E
When migrating from HTTPCLIENT3 to HC4.5.1 (issue is also in HC4.2.3), we have
an issue in behaviour of RFC6265 org.apache.http.client.config.CookieSpec
Following test fails:
{code:java}
@Test
public void testDomainStartingWithDot() {
final BasicClientCookie cookie1 = new BasicClientCookie("id", "value");
cookie1.setPath("/");
cookie1.setDomain(".apache.org");
cookie1.setSecure(false);
cookie1.setExpiryDate(new Date(9999999999L));
URL url;
try {
url = new URL("http://jakarta.apache.org/index.html");
String host = url.getHost();
int port= 80;
String path = url.getPath();
boolean isSecure=false;
CookieOrigin cookieOrigin = new CookieOrigin(host, port, path,
isSecure);
PublicSuffixMatcher publicSuffixMatcher =
PublicSuffixMatcherLoader.getDefault();
Registry<CookieSpecProvider> registry =
RegistryBuilder.<CookieSpecProvider>create()
.register(CookieSpecs.STANDARD, new
RFC6265CookieSpecProvider(publicSuffixMatcher))
.build();
HttpClientContext context = HttpClientContext.create();
CookieSpec cookieSpec =
registry.lookup(CookieSpecs.STANDARD).create(context);
Assert.assertTrue(cookieSpec.match(cookie1, cookieOrigin));
} catch (MalformedURLException e) {
Assert.fail(e.getMessage());
}
}
{code}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]