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 Sam Crawford <sa...@gmail.com> on 2009/06/12 01:21:14 UTC
Sending cookies promiscuously
Evening all,
Is there any way to configure a BasicClientCookie such that if the target
domain for the cookie is unknown, it will be sent to any domain when
executed with an HTTP request?
We've found that if we create a simple BasicClientCookie (setting only a
name and value), add it to a BasicCookieStore, and then attach that cookie
store to a HttpContext, the resulting request will not contain the cookie.
Naturally I understand the reason for this, but I wondered if there was a
way around it (perhaps such that if no domain is set, it sends it
promiscously to anywhere).
Thanks,
Sam
Re: Sending cookies promiscuously
Posted by Oleg Kalnichevski <ol...@apache.org>.
Sam Crawford wrote:
> Evening all,
>
> Is there any way to configure a BasicClientCookie such that if the target
> domain for the cookie is unknown, it will be sent to any domain when
> executed with an HTTP request?
>
> We've found that if we create a simple BasicClientCookie (setting only a
> name and value), add it to a BasicCookieStore, and then attach that cookie
> store to a HttpContext, the resulting request will not contain the cookie.
> Naturally I understand the reason for this, but I wondered if there was a
> way around it (perhaps such that if no domain is set, it sends it
> promiscously to anywhere).
>
> Thanks,
>
> Sam
>
Hi Sam
You basically have to replace the BasicDomainHandler [1] with a custom
implementation:
(1) implement a custom CookieAttributeHandler
(2) register it with the cookie spec of your choice instead of the
default one.
(3) register the custom cookie spec with HttpClient
Hope this helps
Oleg
[1]
http://hc.apache.org/httpcomponents-client/httpclient/xref/org/apache/http/impl/cookie/BasicDomainHandler.html
---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org