Example usage for org.apache.http.impl.client DefaultHttpClient setCookieSpecs

List of usage examples for org.apache.http.impl.client DefaultHttpClient setCookieSpecs

Introduction

In this page you can find the example usage for org.apache.http.impl.client DefaultHttpClient setCookieSpecs.

Prototype

public synchronized void setCookieSpecs(final CookieSpecRegistry registry) 

Source Link

Usage

From source file:org.jboss.as.test.http.util.HttpClientUtils.java

/**
 * Creates a http client that sends cookies to every domain, not just the originator
 *
 * As we don't actually have a load balancer for the clustering tests, we use this instead.
 *
 * @return a http client that gives free cookies to everybody
 *//*from   w w w  .ja  v a 2  s  . co  m*/
public static DefaultHttpClient relaxedCookieHttpClient() {
    DefaultHttpClient client = new DefaultHttpClient();
    final CookieSpecRegistry registry = new CookieSpecRegistry();
    registry.register("best-match", new CookieSpecFactory() {
        @Override
        public CookieSpec newInstance(final HttpParams params) {
            return new RelaxedBrowserCompatSpec();
        }
    });
    client.setCookieSpecs(registry);
    return client;
}