List of usage examples for org.apache.http.client.params CookiePolicy IGNORE_COOKIES
String IGNORE_COOKIES
To view the source code for org.apache.http.client.params CookiePolicy IGNORE_COOKIES.
Click Source Link
From source file:com.jayway.restassured.config.HttpClientConfigTest.java
@Test public void cookiePolicyIsSetToIgnoreCookiesByDefault() throws Exception { final HttpClientConfig httpClientConfig = new HttpClientConfig(); assertThat((Map<String, String>) httpClientConfig.params(), hasEntry(ClientPNames.COOKIE_POLICY, CookiePolicy.IGNORE_COOKIES)); }
From source file:io.restassured.config.HttpClientConfigTest.java
@Test public void cookiePolicyIsSetToIgnoreCookiesByDefault() throws Exception { final HttpClientConfig httpClientConfig = new HttpClientConfig(); assertThat(httpClientConfig.params()) .contains(entry(ClientPNames.COOKIE_POLICY, CookiePolicy.IGNORE_COOKIES)); }
From source file:org.openrepose.core.services.httpclient.impl.HttpConnectionPoolProvider.java
public static HttpClient genClient(PoolType poolConf) { PoolingClientConnectionManager cm = new PoolingClientConnectionManager(); cm.setDefaultMaxPerRoute(poolConf.getHttpConnManagerMaxPerRoute()); cm.setMaxTotal(poolConf.getHttpConnManagerMaxTotal()); //Set all the params up front, instead of mutating them? Maybe this matters HttpParams params = new BasicHttpParams(); params.setParameter(ClientPNames.COOKIE_POLICY, CookiePolicy.IGNORE_COOKIES); params.setBooleanParameter(ClientPNames.HANDLE_REDIRECTS, false); params.setIntParameter(CoreConnectionPNames.SO_TIMEOUT, poolConf.getHttpSocketTimeout()); params.setIntParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, poolConf.getHttpConnectionTimeout()); params.setParameter(CoreConnectionPNames.TCP_NODELAY, poolConf.isHttpTcpNodelay()); params.setParameter(CoreConnectionPNames.MAX_HEADER_COUNT, poolConf.getHttpConnectionMaxHeaderCount()); params.setParameter(CoreConnectionPNames.MAX_LINE_LENGTH, poolConf.getHttpConnectionMaxLineLength()); params.setParameter(CoreConnectionPNames.SOCKET_BUFFER_SIZE, poolConf.getHttpSocketBufferSize()); params.setBooleanParameter(CHUNKED_ENCODING_PARAM, poolConf.isChunkedEncoding()); final String uuid = UUID.randomUUID().toString(); params.setParameter(CLIENT_INSTANCE_ID, uuid); //Pass in the params and the connection manager DefaultHttpClient client = new DefaultHttpClient(cm, params); SSLContext sslContext = ProxyUtilities.getTrustingSslContext(); SSLSocketFactory ssf = new SSLSocketFactory(sslContext, SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER); SchemeRegistry registry = cm.getSchemeRegistry(); Scheme scheme = new Scheme("https", DEFAULT_HTTPS_PORT, ssf); registry.register(scheme);//from w ww . jav a 2s . c o m client.setKeepAliveStrategy(new ConnectionKeepAliveWithTimeoutStrategy(poolConf.getKeepaliveTimeout())); LOG.info("HTTP connection pool {} with instance id {} has been created", poolConf.getId(), uuid); return client; }
From source file:org.jcodec.player.filters.http.HttpMedia.java
private String requestInfo(URL url, HttpClient client) throws IOException { HttpGet get = new HttpGet(url.toExternalForm()); get.getParams().setParameter(ClientPNames.COOKIE_POLICY, CookiePolicy.IGNORE_COOKIES); HttpResponse response = privilegedExecute(client, get); if (response.getStatusLine().getStatusCode() == 200) { return EntityUtils.toString(response.getEntity()); } else/*from w ww .ja v a 2s. co m*/ throw new IOException("Could not get the media info [" + url.toExternalForm() + "]:" + response.getStatusLine().getStatusCode() + " " + response.getStatusLine().getReasonPhrase()); }
From source file:cn.keke.travelmix.HttpClientHelper.java
public static HttpClient getNewHttpClient() { try {/*from ww w . j av a 2 s. com*/ SSLSocketFactory sf = new EasySSLSocketFactory(); // TODO test, if SyncBasicHttpParams is needed HttpParams params = new BasicHttpParams(); HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1); HttpProtocolParams.setContentCharset(params, HTTP.UTF_8); HttpProtocolParams.setUseExpectContinue(params, false); HttpProtocolParams.setHttpElementCharset(params, HTTP.UTF_8); HttpConnectionParams.setConnectionTimeout(params, 10000); HttpConnectionParams.setSocketBufferSize(params, 8192); HttpConnectionParams.setLinger(params, 1); HttpConnectionParams.setStaleCheckingEnabled(params, false); HttpConnectionParams.setSoReuseaddr(params, true); HttpConnectionParams.setTcpNoDelay(params, true); HttpClientParams.setCookiePolicy(params, CookiePolicy.IGNORE_COOKIES); HttpClientParams.setAuthenticating(params, false); HttpClientParams.setRedirecting(params, false); SchemeRegistry registry = new SchemeRegistry(); registry.register(new Scheme("http", 80, PlainSocketFactory.getSocketFactory())); registry.register(new Scheme("https", 443, sf)); ThreadSafeClientConnManager ccm = new ThreadSafeClientConnManager(registry, 20, TimeUnit.MINUTES); ccm.setMaxTotal(100); ccm.setDefaultMaxPerRoute(20); return new DefaultHttpClient(ccm, params); } catch (Exception e) { LOG.warn("Failed to create custom http client. Default http client is created", e); return new DefaultHttpClient(); } }
From source file:org.apache.chemistry.opencmis.client.bindings.spi.http.ApacheClientHttpInvoker.java
@Override protected DefaultHttpClient createHttpClient(UrlBuilder url, BindingSession session) { // set params HttpParams params = createDefaultHttpParams(session); params.setParameter(ClientPNames.COOKIE_POLICY, CookiePolicy.IGNORE_COOKIES); // set up scheme registry and connection manager SchemeRegistry registry = new SchemeRegistry(); registry.register(new Scheme("http", 80, PlainSocketFactory.getSocketFactory())); registry.register(new Scheme("https", 443, getSSLSocketFactory(url, session))); // set up connection manager PoolingClientConnectionManager connManager = new PoolingClientConnectionManager(registry); // set max connection a String keepAliveStr = System.getProperty("http.keepAlive", "true"); if ("true".equalsIgnoreCase(keepAliveStr)) { String maxConnStr = System.getProperty("http.maxConnections", "5"); int maxConn = 5; try {/* ww w . j av a2 s . c o m*/ maxConn = Integer.parseInt(maxConnStr); } catch (NumberFormatException nfe) { // ignore } connManager.setDefaultMaxPerRoute(maxConn); connManager.setMaxTotal(4 * maxConn); } // set up proxy ProxySelectorRoutePlanner routePlanner = new ProxySelectorRoutePlanner(registry, null); // set up client DefaultHttpClient httpclient = new DefaultHttpClient(connManager, params); httpclient.setRoutePlanner(routePlanner); return httpclient; }
From source file:com.base.httpclient.HttpJsonClient.java
/** * httpClient//w w w . ja va2 s . c om * @return */ public static DefaultHttpClient getHttpClient() { SchemeRegistry schemeRegistry = new SchemeRegistry(); schemeRegistry.register(new Scheme("http", 80, PlainSocketFactory.getSocketFactory())); schemeRegistry.register(new Scheme("https", 443, SSLSocketFactory.getSocketFactory())); PoolingClientConnectionManager cm = new PoolingClientConnectionManager(schemeRegistry); HttpParams httpParams = new BasicHttpParams(); cm.setMaxTotal(10);// cm.setDefaultMaxPerRoute(5);// ? HttpConnectionParams.setConnectionTimeout(httpParams, 60000);// HttpConnectionParams.setSoTimeout(httpParams, 60000);//? HttpProtocolParams.setVersion(httpParams, HttpVersion.HTTP_1_1); HttpProtocolParams.setUseExpectContinue(httpParams, false); httpParams.setParameter(ClientPNames.COOKIE_POLICY, CookiePolicy.IGNORE_COOKIES); DefaultHttpClient httpClient = new DefaultHttpClient(cm, httpParams); //httpClient.setCookieStore(null); httpClient.getCookieStore().clear(); httpClient.getCookieStore().getCookies().clear(); // httpClient.setHttpRequestRetryHandler(new HttpJsonClient().new HttpRequestRetry());//? return httpClient; }
From source file:de.fhg.iais.asc.oai.retriever.MetadataFormatsAndSetNamesRetriever.java
public MetadataFormatsAndSetNamesRetriever(String uri, ASCState ascstate, String proxyhost, Integer proxyport) { this.uri = uri; this.ascstate = ascstate; HttpClient client = new DefaultHttpClient(); // set some parameters that might help but will not harm // see: http://hc.apache.org/httpclient-legacy/preference-api.html // the user-agent: // tell them who we are (they see that from the IP anyway), thats a good habit, // shows that we are professional and not some script kiddies // and this is also a little bit of viral marketing :-) client.getParams().setParameter("http.useragent", "myCortex Harvester; http://www.iais.fraunhofer.de/"); // the following option "can result in noticeable performance improvement" (see api docs) // it may switch on a keep-alive, may reduce load on server side (if they are smart) // and might reduce latency client.getParams().setParameter("http.protocol.expect-continue", true); // ignore all cookies because some OAI-PMH implementations don't know how to handle cookies client.getParams().setParameter(ClientPNames.COOKIE_POLICY, CookiePolicy.IGNORE_COOKIES); // setting of the proxy if needed if (proxyhost != null && !proxyhost.isEmpty()) { HttpHost proxy = new HttpHost(proxyhost, proxyport); client.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy); }// w w w . j av a 2 s.com this.server = new OaiPmhServer(client, this.uri); }