You are viewing a plain text version of this content. The canonical link for it is here.
Posted to httpclient-users@hc.apache.org by aljesco <al...@gmail.com> on 2011/03/26 15:30:15 UTC

HttpClient & Cookie2

Hello,

Is there any way to get rid of "Cookie2: $Version=1" parameter in
request executing?

e.g., when I'm running next code,

CookieStore cookieStore = new BasicCookieStore();
HttpContext localContext = new BasicHttpContext();
localContext.setAttribute(ClientContext.COOKIE_STORE, cookieStore);

HttpGet httpget = new HttpGet("http://www.google.com/");
HttpResponse response = httpclient.execute(httpget, localContext);
HttpEntity entity = response.getEntity();

EntityUtils.consume(entity);
httpclient.execute(httpget, localContext);

at first responce server sets only
Set-Cookie:xxxxxxxx
but httpClient sends both headers, cookie and cookie2:
Cookie: xxxxxxxx
Cookie2: $Version=1

Any ideas?

Thanks

---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org


Re: HttpClient & Cookie2

Posted by aljesco <al...@gmail.com>.
2011/3/26 aljesco <al...@gmail.com>:
> 2011/3/26 Oleg Kalnichevski <ol...@apache.org>:
>> On Sat, 2011-03-26 at 16:30 +0200, aljesco wrote:
>>> Hello,
>>>
>>> Is there any way to get rid of "Cookie2: $Version=1" parameter in
>>> request executing?
>>>
>>> e.g., when I'm running next code,
>>>
>>> CookieStore cookieStore = new BasicCookieStore();
>>> HttpContext localContext = new BasicHttpContext();
>>> localContext.setAttribute(ClientContext.COOKIE_STORE, cookieStore);
>>>
>>> HttpGet httpget = new HttpGet("http://www.google.com/");
>>> HttpResponse response = httpclient.execute(httpget, localContext);
>>> HttpEntity entity = response.getEntity();
>>>
>>> EntityUtils.consume(entity);
>>> httpclient.execute(httpget, localContext);
>>>
>>> at first responce server sets only
>>> Set-Cookie:xxxxxxxx
>>> but httpClient sends both headers, cookie and cookie2:
>>> Cookie: xxxxxxxx
>>> Cookie2: $Version=1
>>>
>>> Any ideas?
>>>
>>
>> 'Cookie2: $Version=1' header merely signals to the server that the
>> client supports RFC 2965 specification and can accept Set-Cookie2
>> headers.
>>
>> Why do you want to get rid of this header?
>>
>> Oleg
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
>> For additional commands, e-mail: httpclient-users-help@hc.apache.org
>>
>>
>
> I just don't want the client to signal that it supports cookie v2 :)
>
> As I remember, in HttpClient v3 existed way to specify 'old' cookie policy:
> httpclient.getParams().setCookiePolicy(CookiePolicy.RFC_2109);
> or
> httpclient.getParams().setCookiePolicy(CookiePolicy.BROWSER_COMPATIBILITY);
>
> In HttpClient 4, there's no method setCookiePolicy in HttpParams..
> So, can I do the same thing with new HttpClient?
>
> Thank you for help, Oleg
>

ohhh...I think I did it.

httpget.getParams().setParameter(
                    ClientPNames.COOKIE_POLICY, CookiePolicy.NETSCAPE);

Search in source code rules!
Thanks again

---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org


Re: HttpClient & Cookie2

Posted by aljesco <al...@gmail.com>.
2011/3/26 Oleg Kalnichevski <ol...@apache.org>:
> On Sat, 2011-03-26 at 16:30 +0200, aljesco wrote:
>> Hello,
>>
>> Is there any way to get rid of "Cookie2: $Version=1" parameter in
>> request executing?
>>
>> e.g., when I'm running next code,
>>
>> CookieStore cookieStore = new BasicCookieStore();
>> HttpContext localContext = new BasicHttpContext();
>> localContext.setAttribute(ClientContext.COOKIE_STORE, cookieStore);
>>
>> HttpGet httpget = new HttpGet("http://www.google.com/");
>> HttpResponse response = httpclient.execute(httpget, localContext);
>> HttpEntity entity = response.getEntity();
>>
>> EntityUtils.consume(entity);
>> httpclient.execute(httpget, localContext);
>>
>> at first responce server sets only
>> Set-Cookie:xxxxxxxx
>> but httpClient sends both headers, cookie and cookie2:
>> Cookie: xxxxxxxx
>> Cookie2: $Version=1
>>
>> Any ideas?
>>
>
> 'Cookie2: $Version=1' header merely signals to the server that the
> client supports RFC 2965 specification and can accept Set-Cookie2
> headers.
>
> Why do you want to get rid of this header?
>
> Oleg
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> For additional commands, e-mail: httpclient-users-help@hc.apache.org
>
>

I just don't want the client to signal that it supports cookie v2 :)

As I remember, in HttpClient v3 existed way to specify 'old' cookie policy:
httpclient.getParams().setCookiePolicy(CookiePolicy.RFC_2109);
or
httpclient.getParams().setCookiePolicy(CookiePolicy.BROWSER_COMPATIBILITY);

In HttpClient 4, there's no method setCookiePolicy in HttpParams..
So, can I do the same thing with new HttpClient?

Thank you for help, Oleg

---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org


Re: HttpClient & Cookie2

Posted by Oleg Kalnichevski <ol...@apache.org>.
On Sat, 2011-03-26 at 16:30 +0200, aljesco wrote:
> Hello,
> 
> Is there any way to get rid of "Cookie2: $Version=1" parameter in
> request executing?
> 
> e.g., when I'm running next code,
> 
> CookieStore cookieStore = new BasicCookieStore();
> HttpContext localContext = new BasicHttpContext();
> localContext.setAttribute(ClientContext.COOKIE_STORE, cookieStore);
> 
> HttpGet httpget = new HttpGet("http://www.google.com/");
> HttpResponse response = httpclient.execute(httpget, localContext);
> HttpEntity entity = response.getEntity();
> 
> EntityUtils.consume(entity);
> httpclient.execute(httpget, localContext);
> 
> at first responce server sets only
> Set-Cookie:xxxxxxxx
> but httpClient sends both headers, cookie and cookie2:
> Cookie: xxxxxxxx
> Cookie2: $Version=1
> 
> Any ideas?
> 

'Cookie2: $Version=1' header merely signals to the server that the
client supports RFC 2965 specification and can accept Set-Cookie2
headers. 

Why do you want to get rid of this header?

Oleg



---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org