Thank you very much for the help!

So to my understanding after reading the code for BrowserCompatSpec [0] is
that when using the "CookieSpecs.BROWSER_COMPATIBILITY" when building the
cookie spec the single cookie header policy is already in place?


[0]
https://svn.apache.org/repos/asf/httpcomponents/httpclient/tags/4.3.3/httpclient/src/main/java/org/apache/http/impl/cookie/BrowserCompatSpec.java


On Tue, May 6, 2014 at 3:43 PM, <[email protected]> wrote:

> Hi.
>
> From the Chapter 3 of "HttpClient Tutorial" [1] it seems that that can be
> achieved by registering a CookieSpecProvider [2], for example, and using
> BestMatchSpecFactory [3]:
>
>> Registry<CookieSpecProvider> r = RegistryBuilder.<CookieSpecProvider>
>> create()
>>         // override default behaviour of BEST_MATCH (2nd arg of
>> BestMatchSpecFactory's constructor specifies "single cookie header")
>>         .register(CookieSpecs.BEST_MATCH, new BestMatchSpecFactory(null,
>> true))
>>         // or use "custom" cookie spec, register other cookie specs as
>> needed
>>         .register("oneheader-best-match", new BestMatchSpecFactory(null,
>> true))
>>         .build();
>>
>> RequestConfig requestConfig = RequestConfig.custom()
>>         .setCookieSpec("oneheader-best-match")
>>         .build();
>>
>> CloseableHttpClient httpclient = HttpClients.custom()
>>         .setDefaultCookieSpecRegistry(r)
>>         .setDefaultRequestConfig(requestConfig)
>>         .build();
>>
> (Note: code _not_ tested)
>
> For reference, the default CookieSpecProvider registry created by
> HttpClientBuilder, as of version 4.3.3 [4], is:
>
>> cookieSpecRegistry = RegistryBuilder.<CookieSpecProvider>create()
>>         .register(CookieSpecs.BEST_MATCH, new BestMatchSpecFactory())
>>         .register(CookieSpecs.STANDARD, new RFC2965SpecFactory())
>>         .register(CookieSpecs.BROWSER_COMPATIBILITY, new
>> BrowserCompatSpecFactory())
>>         .register(CookieSpecs.NETSCAPE, new NetscapeDraftSpecFactory())
>>         .register(CookieSpecs.IGNORE_COOKIES, new IgnoreSpecFactory())
>>         .register("rfc2109", new RFC2109SpecFactory())
>>         .register("rfc2965", new RFC2965SpecFactory())
>>         .build();
>>
>
> HTH.
> Best regards.
>
> [1] https://hc.apache.org/httpcomponents-client-4.3.x/
> tutorial/html/statemgmt.html#d5e557
> [2] https://hc.apache.org/httpcomponents-client-4.3.x/
> httpclient/apidocs/org/apache/http/cookie/CookieSpecProvider.html
> [3] https://hc.apache.org/httpcomponents-client-4.3.x/
> httpclient/apidocs/org/apache/http/impl/cookie/BestMatchSpec.html
> [4] https://svn.apache.org/repos/asf/httpcomponents/httpclient/
> tags/4.3.3/httpclient/src/main/java/org/apache/http/
> impl/client/HttpClientBuilder.java
>
>
> On 06/05/14 08:11, d_k wrote:
>
>> Hello,
>>
>> I'm porting httpclient 3 code to the 4.3 API and I was unable to find a
>> way
>> to set the single-cookie-header setting using the 4.3 API
>>
>> The original line states:
>> params.setBooleanParameter(HttpMethodParams.SINGLE_COOKIE_HEADER, true);
>>
>> And I was wondering how to write it with the 4.3 API.
>>
>> If it helps I think the 4.1.1 API is something like this:
>>
>> params.setBooleanParameter(CookieSpecPNames.SINGLE_COOKIE_HEADER, true);
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>

Reply via email to