All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.logspace.agent.shaded.apache.http.impl.client.DefaultHttpClient Maven / Gradle / Ivy

There is a newer version: 0.3.2
Show newest version
/*
 * ====================================================================
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 * ====================================================================
 *
 * This software consists of voluntary contributions made by many
 * individuals on behalf of the Apache Software Foundation.  For more
 * information on the Apache Software Foundation, please see
 * .
 *
 */

package io.logspace.agent.shaded.apache.http.impl.client;

import io.logspace.agent.shaded.apache.http.HttpVersion;
import io.logspace.agent.shaded.apache.http.annotation.ThreadSafe;
import io.logspace.agent.shaded.apache.http.client.protocol.RequestAddCookies;
import io.logspace.agent.shaded.apache.http.client.protocol.RequestAuthCache;
import io.logspace.agent.shaded.apache.http.client.protocol.RequestClientConnControl;
import io.logspace.agent.shaded.apache.http.client.protocol.RequestDefaultHeaders;
import io.logspace.agent.shaded.apache.http.client.protocol.RequestProxyAuthentication;
import io.logspace.agent.shaded.apache.http.client.protocol.RequestTargetAuthentication;
import io.logspace.agent.shaded.apache.http.client.protocol.ResponseProcessCookies;
import io.logspace.agent.shaded.apache.http.conn.ClientConnectionManager;
import io.logspace.agent.shaded.apache.http.params.HttpConnectionParams;
import io.logspace.agent.shaded.apache.http.params.HttpParams;
import io.logspace.agent.shaded.apache.http.params.HttpProtocolParams;
import io.logspace.agent.shaded.apache.http.params.SyncBasicHttpParams;
import io.logspace.agent.shaded.apache.http.protocol.BasicHttpProcessor;
import io.logspace.agent.shaded.apache.http.protocol.HTTP;
import io.logspace.agent.shaded.apache.http.protocol.RequestContent;
import io.logspace.agent.shaded.apache.http.protocol.RequestExpectContinue;
import io.logspace.agent.shaded.apache.http.protocol.RequestTargetHost;
import io.logspace.agent.shaded.apache.http.protocol.RequestUserAgent;

/**
 * Default implementation of {@link io.logspace.agent.shaded.apache.http.client.HttpClient} pre-configured
 * for most common use scenarios.
 * 

* Please see the Javadoc for {@link #createHttpProcessor()} for the details of the interceptors * that are set up by default. *

* Additional interceptors can be added as follows, but * take care not to add the same interceptor more than once. *

 * DefaultHttpClient httpclient = new DefaultHttpClient();
 * httpclient.addRequestInterceptor(new RequestAcceptEncoding());
 * httpclient.addResponseInterceptor(new ResponseContentEncoding());
 * 
*

* This class sets up the following parameters if not explicitly set: *

    *
  • Version: HttpVersion.HTTP_1_1
  • *
  • ContentCharset: HTTP.DEFAULT_CONTENT_CHARSET
  • *
  • NoTcpDelay: true
  • *
  • SocketBufferSize: 8192
  • *
  • UserAgent: Apache-HttpClient/release (java 1.5)
  • *
*

* The following parameters can be used to customize the behavior of this * class: *

    *
  • {@link io.logspace.agent.shaded.apache.http.params.CoreProtocolPNames#PROTOCOL_VERSION}
  • *
  • {@link io.logspace.agent.shaded.apache.http.params.CoreProtocolPNames#STRICT_TRANSFER_ENCODING}
  • *
  • {@link io.logspace.agent.shaded.apache.http.params.CoreProtocolPNames#HTTP_ELEMENT_CHARSET}
  • *
  • {@link io.logspace.agent.shaded.apache.http.params.CoreProtocolPNames#USE_EXPECT_CONTINUE}
  • *
  • {@link io.logspace.agent.shaded.apache.http.params.CoreProtocolPNames#WAIT_FOR_CONTINUE}
  • *
  • {@link io.logspace.agent.shaded.apache.http.params.CoreProtocolPNames#USER_AGENT}
  • *
  • {@link io.logspace.agent.shaded.apache.http.params.CoreConnectionPNames#TCP_NODELAY}
  • *
  • {@link io.logspace.agent.shaded.apache.http.params.CoreConnectionPNames#SO_TIMEOUT}
  • *
  • {@link io.logspace.agent.shaded.apache.http.params.CoreConnectionPNames#SO_LINGER}
  • *
  • {@link io.logspace.agent.shaded.apache.http.params.CoreConnectionPNames#SO_REUSEADDR}
  • *
  • {@link io.logspace.agent.shaded.apache.http.params.CoreConnectionPNames#SOCKET_BUFFER_SIZE}
  • *
  • {@link io.logspace.agent.shaded.apache.http.params.CoreConnectionPNames#CONNECTION_TIMEOUT}
  • *
  • {@link io.logspace.agent.shaded.apache.http.params.CoreConnectionPNames#MAX_LINE_LENGTH}
  • *
  • {@link io.logspace.agent.shaded.apache.http.params.CoreConnectionPNames#MAX_HEADER_COUNT}
  • *
  • {@link io.logspace.agent.shaded.apache.http.params.CoreConnectionPNames#STALE_CONNECTION_CHECK}
  • *
  • {@link io.logspace.agent.shaded.apache.http.conn.params.ConnRoutePNames#FORCED_ROUTE}
  • *
  • {@link io.logspace.agent.shaded.apache.http.conn.params.ConnRoutePNames#LOCAL_ADDRESS}
  • *
  • {@link io.logspace.agent.shaded.apache.http.conn.params.ConnRoutePNames#DEFAULT_PROXY}
  • *
  • {@link io.logspace.agent.shaded.apache.http.cookie.params.CookieSpecPNames#DATE_PATTERNS}
  • *
  • {@link io.logspace.agent.shaded.apache.http.cookie.params.CookieSpecPNames#SINGLE_COOKIE_HEADER}
  • *
  • {@link io.logspace.agent.shaded.apache.http.auth.params.AuthPNames#CREDENTIAL_CHARSET}
  • *
  • {@link io.logspace.agent.shaded.apache.http.client.params.ClientPNames#COOKIE_POLICY}
  • *
  • {@link io.logspace.agent.shaded.apache.http.client.params.ClientPNames#HANDLE_AUTHENTICATION}
  • *
  • {@link io.logspace.agent.shaded.apache.http.client.params.ClientPNames#HANDLE_REDIRECTS}
  • *
  • {@link io.logspace.agent.shaded.apache.http.client.params.ClientPNames#MAX_REDIRECTS}
  • *
  • {@link io.logspace.agent.shaded.apache.http.client.params.ClientPNames#ALLOW_CIRCULAR_REDIRECTS}
  • *
  • {@link io.logspace.agent.shaded.apache.http.client.params.ClientPNames#VIRTUAL_HOST}
  • *
  • {@link io.logspace.agent.shaded.apache.http.client.params.ClientPNames#DEFAULT_HOST}
  • *
  • {@link io.logspace.agent.shaded.apache.http.client.params.ClientPNames#DEFAULT_HEADERS}
  • *
  • {@link io.logspace.agent.shaded.apache.http.client.params.ClientPNames#CONN_MANAGER_TIMEOUT}
  • *
* * @since 4.0 * * @deprecated (4.3) use {@link HttpClientBuilder}. */ @ThreadSafe @Deprecated public class DefaultHttpClient extends AbstractHttpClient { /** * Creates a new HTTP client from parameters and a connection manager. * * @param params the parameters * @param conman the connection manager */ public DefaultHttpClient( final ClientConnectionManager conman, final HttpParams params) { super(conman, params); } /** * @since 4.1 */ public DefaultHttpClient( final ClientConnectionManager conman) { super(conman, null); } public DefaultHttpClient(final HttpParams params) { super(null, params); } public DefaultHttpClient() { super(null, null); } /** * Creates the default set of HttpParams by invoking {@link DefaultHttpClient#setDefaultHttpParams(HttpParams)} * * @return a new instance of {@link SyncBasicHttpParams} with the defaults applied to it. */ @Override protected HttpParams createHttpParams() { final HttpParams params = new SyncBasicHttpParams(); setDefaultHttpParams(params); return params; } /** * Saves the default set of HttpParams in the provided parameter. * These are: *
    *
  • {@link io.logspace.agent.shaded.apache.http.params.CoreProtocolPNames#PROTOCOL_VERSION}: * 1.1
  • *
  • {@link io.logspace.agent.shaded.apache.http.params.CoreProtocolPNames#HTTP_CONTENT_CHARSET}: * ISO-8859-1
  • *
  • {@link io.logspace.agent.shaded.apache.http.params.CoreConnectionPNames#TCP_NODELAY}: * true
  • *
  • {@link io.logspace.agent.shaded.apache.http.params.CoreConnectionPNames#SOCKET_BUFFER_SIZE}: * 8192
  • *
  • {@link io.logspace.agent.shaded.apache.http.params.CoreProtocolPNames#USER_AGENT}: * Apache-HttpClient/ (java 1.5)
  • *
*/ public static void setDefaultHttpParams(final HttpParams params) { HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1); HttpProtocolParams.setContentCharset(params, HTTP.DEF_CONTENT_CHARSET.name()); HttpConnectionParams.setTcpNoDelay(params, true); HttpConnectionParams.setSocketBufferSize(params, 8192); HttpProtocolParams.setUserAgent(params, HttpClientBuilder.DEFAULT_USER_AGENT); } /** * Create the processor with the following interceptors: *
    *
  • {@link RequestDefaultHeaders}
  • *
  • {@link RequestContent}
  • *
  • {@link RequestTargetHost}
  • *
  • {@link RequestClientConnControl}
  • *
  • {@link RequestUserAgent}
  • *
  • {@link RequestExpectContinue}
  • *
  • {@link RequestAddCookies}
  • *
  • {@link ResponseProcessCookies}
  • *
  • {@link RequestAuthCache}
  • *
  • {@link RequestTargetAuthentication}
  • *
  • {@link RequestProxyAuthentication}
  • *
*

* @return the processor with the added interceptors. */ @Override protected BasicHttpProcessor createHttpProcessor() { final BasicHttpProcessor httpproc = new BasicHttpProcessor(); httpproc.addInterceptor(new RequestDefaultHeaders()); // Required protocol interceptors httpproc.addInterceptor(new RequestContent()); httpproc.addInterceptor(new RequestTargetHost()); // Recommended protocol interceptors httpproc.addInterceptor(new RequestClientConnControl()); httpproc.addInterceptor(new RequestUserAgent()); httpproc.addInterceptor(new RequestExpectContinue()); // HTTP state management interceptors httpproc.addInterceptor(new RequestAddCookies()); httpproc.addInterceptor(new ResponseProcessCookies()); // HTTP authentication interceptors httpproc.addInterceptor(new RequestAuthCache()); httpproc.addInterceptor(new RequestTargetAuthentication()); httpproc.addInterceptor(new RequestProxyAuthentication()); return httpproc; } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy