Sending cookies promiscuously

View: New views
2 Messages — Rating Filter:   Alert me  

Sending cookies promiscuously

by Sam Crawford :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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

by olegk :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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@...
For additional commands, e-mail: httpclient-users-help@...