dev@jersey.java.net

Re: [Jersey] How to set cookie policy using jersey client

From: Paul Sandoz <Paul.Sandoz_at_oracle.com>
Date: Mon, 30 Aug 2010 11:52:41 +0200

On Aug 27, 2010, at 8:45 PM, Srikanth Martha wrote:

> I have the following code
>
> DefaultApacheHttpClientConfig apcc = new
> DefaultApacheHttpClientConfig();
>
> apcc
> .getProperties
> ().put(DefaultApacheHttpClientConfig.PROPERTY_HANDLE_COOKIES, true);
>
> apcc.getProperties().put(ClientConfig.PROPERTY_FOLLOW_REDIRECTS,
> false);
>
> apcc.getProperties().put(ClientConfig.PROPERTY_CONNECT_TIMEOUT,
> 10*1000);
> apcc.getProperties().put(ClientConfig.PROPERTY_READ_TIMEOUT,
> 30*1000);
>
> ApacheHttpClient jerseyClient = ApacheHttpClient.create(apcc);
>
> WebResource r = novaResource.path("some_path");
> NovaWorkflowBean response =
> r.accept(MediaType.APPLICATION_JSON)
> .cookie(ybyCookie)
> .get(MyBean.class);
>
> whenever I make webservices calls using the above , I see the
> following logs which I would like to ignore by setting the
> equivalent of CookiePolicy.BROWSER_COMPATIBILITY in HttpClient.
>

You can obtain the HttpClient instance by calling:

   jerseyClient.getApacheHttpClientHandler().getHttpClient().

Paul.


> 2010-08-13 20:40:13,063 WARN
> org.apache.commons.httpclient.HttpMethodBase - Cookie rejected:
> "$Version=0; B=atae73l66bbdd&b=3&s=ca; $Path=/; $Domain=.xxxx".
> Domain attr
> ibute "xxx" violates RFC 2109: host minus domain may not contain any
> dots
> 2010-08-13 20:40:13,218 WARN
> org.apache.commons.httpclient.HttpMethodBase - Cookie rejected:
> "$Version=0; B=chns9n566bbdd&b=3&s=79; $Path=/; $Domain=xxx". Domain
> attr
> ibute "xxx" violates RFC 2109: host minus domain may not contain any
> dots
>
> How do I achieve that.
>
> Thanks
> --Sreekanth