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 Michael Becke <mb...@gmail.com> on 2005/07/02 04:32:08 UTC

Re: Setting Cookie Policy

Could you be more specific about what does not work?  What do you mean
you want it to accept or reject cookies, surely it must do one or the
other out of the box.  Perhaps you could post some sample code and a
wire log showing the issue in question.

<http://jakarta.apache.org/commons/httpclient/logging.html>

Mike

On 6/30/05, Alexander Fairley <al...@gmail.com> wrote:
> Hi guys,
> I'm attempting to convince the HttpClient to accept, or ignore cookies
> with the domain set to .foobar.com from Domain of origin: foobar.com.
> I'm using 3.0rc2, and so far I've tried:
> 
> CookiePolicy.registerCookieSpec(CookiePolicy.DEFAULT,
> CookiePolicy.getCookieSpec(CookiePolicy.BROWSER_COMPATIBILITY).getClass());
> 
> as well as using CookiePolicy.IGNORE_COOKIES. I've also attempted to
> use the deprecated version
>  CookiePolicy.setDefaultPolicy();
> 
> but have had no luck either way.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: httpclient-user-help@jakarta.apache.org
> 
>

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


Fwd: Setting Cookie Policy

Posted by Alexander Fairley <al...@gmail.com>.
---------- Forwarded message ----------
From: Alexander Fairley <al...@gmail.com>
Date: Jul 12, 2005 9:22 AM
Subject: Re: Setting Cookie Policy
To: Michael Becke <mb...@gmail.com>


Thanks Mike, but I'm not entirely sure that what you are suggesting
works. Since we've built our own Cookie Management Layer, the best
solution for us at this point is to disable HttpClient's cookie
function completely. I'm attempting to do this by putting this in the
constructor for our HttpClientWrapper:
        CookiePolicy.registerCookieSpec(CookiePolicy.DEFAULT,

CookiePolicy.getCookieSpec(CookiePolicy.IGNORE_COOKIES).getClass());

which is what I put together based on the documentation's suggestion of:

        CookiePolicy.registerCookieSpec(CookiePolicy.DEFAULT, <Some
CookieSpec>);

Regarding your suggestion of :

        CookiePolicy.registerCookieSpec(CookiePolicy.DEFAULT,
IgnoreCookieSpec.class)

I've grepped in the rc3 source for IgnoreCookieSpec to no avail, so
I'm assuming that

IgnoreCookieSpec.class ==
CookiePolicy.getCookieSpec(CookiePolicy.IGNORE_COOKIES).getClass()

If this isn't the case, and IgnoreCookieSpec.class is different, do I
need to check out the source from subversion to get this object, or am
I just not finding it in rc3?

Thanks for your help,

Alexander



On 7/6/05, Michael Becke <mb...@gmail.com> wrote:
> Hi Alexander,
>
> > According to the documentation, HttpClient follows the RFC_2109 cookie
> > ...
> > complaining every now and then about suspicious cookies. Also, once
> > I've figured out how to do this in the current code environment, I'll
> > write up some documentation that you folks can include for the next
> > guy to come along.
>
> Sounds like you want to try the compatibility (CookieSpecBase) policy.
>
> > How exactly does one set the client's cookie policy in the current environment?
>
> As per the cookie documentation
> <http://jakarta.apache.org/commons/httpclient/cookies.html>:
>
> Configuring per method:
> HttpMethod method = new GetMethod();
> method.getParams().setCookiePolicy(CookiePolicy.IGNORE_COOKIES);
> or
> method.getParams().setCookiePolicy(CookiePolicy.COMPATABILITY);
>
> Configuring globally:
> CookiePolicy.registerCookieSpec(CookiePolicy.DEFAULT, IgnoreCookieSpec.class)
> or
> CookiePolicy.registerCookieSpec(CookiePolicy.DEFAULT, CookieSpecBase.class)
>
> Mike
>

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