I believe this is because as of 4.4 they added support for RFC 6265 and deprecated (but kept as default) old policy. Then in 4.5 dropped old.
Specifically this change https://github.com/apache/httpclient/blob/70489c4bb03491b6ea0bec60904fc78782963a3a/httpclient/src/main/java/org/apache/http/impl/cookie/BasicDomainHandler.java#L121 if (domain.startsWith(".")) { domain = domain.substring(1); } Which means the returned domain name would be bt.com instead of .bt.com ? RFC 6256 http://tools.ietf.org/html/rfc6265#section-5.2.3 If the first character of the attribute-value string is %x2E ("."): Let cookie-domain be the attribute-value without the leading %x2E (".") character. On Tue, Oct 27, 2015 at 11:32 AM, Andrey Pokhilko <[email protected]> wrote: > Hi, > > Today we've found an issue in using HTTPClient 4.5 in JMeter. If we just > replace the libraries with no change to JMeter code, it stops processing > wildcard domains for cookies. I've failed to understand if it is > regression in HTTPClient or something else. > > I've managed to write a unit test for it, I can commit it into trunk if > needed. Unit test works fine on old libraries, but fails with 4.5: > > package org.apache.jmeter.protocol.http.control; > > import org.apache.http.cookie.Cookie; > import org.apache.jmeter.testelement.property.CollectionProperty; > import org.junit.Assert; > import org.junit.Test; > > import java.net.URL; > import java.util.List; > > public class HC4CookieHandlerTest { > > @Test public void testAddCookieFromHeader_wildcard() throws Exception { > HC4CookieHandler obj = new HC4CookieHandler("compatibility"); > URL url = new URL("https://subdomain.bt.com/page"); > CookieManager mgr = new CookieManager(); > String headerLine = "SMTRYNO=1; path=/; domain=.bt.com"; > obj.addCookieFromHeader(mgr, true, headerLine, url); > CollectionProperty cp = mgr.getCookies(); > List<Cookie> res = obj.getCookiesForUrl(cp, url, false); > Assert.assertEquals(1, res.size()); > for (Cookie cookie : res) { > Assert.assertEquals(".bt.com", cookie.getDomain()); > } > } > } > > > > Andrey Pokhilko > > On 07/04/2015 05:35 PM, Philippe Mouawad wrote: > > Hello, > > HttpClient 4.3 introduced a new set of APIs which makes migration from > > 4.2.3 to 4.5 an important work. > > > > What are the risks and what do you think about the approach of > progressive > > migration: > > > > - We upgrade to 4.5 HttpClient/Mime and 4.4.1 (HttpCore) jars which > > show many deprecations but not broken compilation > > - Once done, we move progressively (not always possible) to 4.5 the > code > > > > If this is feasible then it would allow us to fix : > > > > - https://bz.apache.org/bugzilla/show_bug.cgi?id=57935 > > > > > > Any trace of a migration documentation from 4.2.X to 4.3. ? > > > > -- Richard Friedman 609.314.0129
