Class ApacheHttpTransport
Implementation is thread-safe, as long as any parameter modification to the Apache HTTP Client is only done at initialization time. For maximum efficiency,
applications should use a single globally-shared instance of the HTTP transport.
Default settings are specified in newDefaultHttpClient(). Use the ApacheHttpTransport(HttpClient) constructor to override the Apache HTTP Client used.
Alternatively, use ApacheHttpTransport() and change the getHttpClient(). Please
read the Apache HTTP
Client connection management tutorial for more complex configuration options.
- Since:
- 1.0
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final org.apache.http.client.HttpClientDeprecated.Apache HTTP client. -
Constructor Summary
ConstructorsConstructorDescriptionDeprecated.Constructor that usesnewDefaultHttpClient()for the Apache HTTP client.ApacheHttpTransport(org.apache.http.client.HttpClient httpClient) Deprecated.Constructor that allows an alternative Apache HTTP client to be used. -
Method Summary
Modifier and TypeMethodDescriptionprotected ApacheHttpRequestbuildRequest(String method, String url) Deprecated.Builds a low level HTTP request for the given HTTP method.org.apache.http.client.HttpClientDeprecated.Returns the Apache HTTP client.static org.apache.http.impl.client.DefaultHttpClientDeprecated.Creates a new instance of the Apache HTTP client that is used by theApacheHttpTransport()constructor.(package private) static org.apache.http.impl.client.DefaultHttpClientnewDefaultHttpClient(org.apache.http.conn.ssl.SSLSocketFactory socketFactory, org.apache.http.params.HttpParams params, ProxySelector proxySelector) Deprecated.Creates a new instance of the Apache HTTP client that is used by theApacheHttpTransport()constructor.(package private) static org.apache.http.params.HttpParamsDeprecated.Returns a new instance of the default HTTP parameters we use.voidshutdown()Deprecated.Shuts down the connection manager and releases allocated resources.booleansupportsMethod(String method) Deprecated.Returns whether a specified HTTP method is supported by this transport.Methods inherited from class HttpTransport
createRequestFactory, createRequestFactory, isMtls, isShutdown
-
Field Details
-
httpClient
private final org.apache.http.client.HttpClient httpClientDeprecated.Apache HTTP client.
-
-
Constructor Details
-
ApacheHttpTransport
public ApacheHttpTransport()Deprecated.Constructor that usesnewDefaultHttpClient()for the Apache HTTP client.Use
ApacheHttpTransport.Builderto modify HTTP client options.- Since:
- 1.3
-
ApacheHttpTransport
public ApacheHttpTransport(org.apache.http.client.HttpClient httpClient) Deprecated.Constructor that allows an alternative Apache HTTP client to be used.Note that a few settings are overridden:
- HTTP version is set to 1.1 using
HttpProtocolParams.setVersion(HttpParams, ProtocolVersion)withHttpVersion.HTTP_1_1. - Redirects are disabled using
ClientPNames.HANDLE_REDIRECTS. ConnManagerParams.setTimeout(HttpParams, long)andHttpConnectionParams.setConnectionTimeout(HttpParams, int)are set on each request based onHttpRequest.getConnectTimeout().HttpConnectionParams.setSoTimeout(HttpParams, int)is set on each request based onHttpRequest.getReadTimeout().
Use
ApacheHttpTransport.Builderfor a more user-friendly way to modify the HTTP client options.- Parameters:
httpClient- Apache HTTP client to use- Since:
- 1.6
- HTTP version is set to 1.1 using
-
-
Method Details
-
newDefaultHttpClient
public static org.apache.http.impl.client.DefaultHttpClient newDefaultHttpClient()Deprecated.Creates a new instance of the Apache HTTP client that is used by theApacheHttpTransport()constructor.Use this constructor if you want to customize the default Apache HTTP client. Settings:
- The client connection manager is set to
ThreadSafeClientConnManager. - The socket buffer size is set to 8192 using
HttpConnectionParams.setSocketBufferSize(HttpParams, int). - invalid input: '<'The retry mechanism is turned off by setting
new DefaultHttpRequestRetryHandler(0, false). - The route planner uses
ProxySelectorRoutePlannerwithProxySelector.getDefault(), which uses the proxy settings from system properties.
- Returns:
- new instance of the Apache HTTP client
- Since:
- 1.6
- The client connection manager is set to
-
newDefaultHttpParams
static org.apache.http.params.HttpParams newDefaultHttpParams()Deprecated.Returns a new instance of the default HTTP parameters we use. -
newDefaultHttpClient
static org.apache.http.impl.client.DefaultHttpClient newDefaultHttpClient(org.apache.http.conn.ssl.SSLSocketFactory socketFactory, org.apache.http.params.HttpParams params, ProxySelector proxySelector) Deprecated.Creates a new instance of the Apache HTTP client that is used by theApacheHttpTransport()constructor.- Parameters:
socketFactory- SSL socket factoryparams- HTTP parametersproxySelector- HTTP proxy selector to useProxySelectorRoutePlannerornullforDefaultHttpRoutePlanner- Returns:
- new instance of the Apache HTTP client
-
supportsMethod
Deprecated.Description copied from class:HttpTransportReturns whether a specified HTTP method is supported by this transport.Default implementation returns true if and only if the request method is
"DELETE","GET","POST", or"PUT". Subclasses should override.- Overrides:
supportsMethodin classHttpTransport- Parameters:
method- HTTP method
-
buildRequest
Deprecated.Description copied from class:HttpTransportBuilds a low level HTTP request for the given HTTP method.- Specified by:
buildRequestin classHttpTransport- Parameters:
method- HTTP methodurl- URL- Returns:
- new low level HTTP request
-
shutdown
public void shutdown()Deprecated.Shuts down the connection manager and releases allocated resources. This includes closing all connections, whether they are currently used or not.- Overrides:
shutdownin classHttpTransport- Since:
- 1.4
-
getHttpClient
public org.apache.http.client.HttpClient getHttpClient()Deprecated.Returns the Apache HTTP client.- Since:
- 1.5
-