@Deprecated public final class ApacheHttpTransport extends HttpTransport
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.
Modifier and Type | Class and Description |
---|---|
static class |
ApacheHttpTransport.Builder
Deprecated.
Builder for
ApacheHttpTransport . |
Constructor and Description |
---|
ApacheHttpTransport()
Deprecated.
Constructor that uses
newDefaultHttpClient() for the Apache HTTP client. |
ApacheHttpTransport(org.apache.http.client.HttpClient httpClient)
Deprecated.
Constructor that allows an alternative Apache HTTP client to be used.
|
Modifier and Type | Method and Description |
---|---|
protected com.google.api.client.http.apache.ApacheHttpRequest |
buildRequest(String method,
String url)
Deprecated.
Builds a low level HTTP request for the given HTTP method.
|
org.apache.http.client.HttpClient |
getHttpClient()
Deprecated.
Returns the Apache HTTP client.
|
static org.apache.http.impl.client.DefaultHttpClient |
newDefaultHttpClient()
Deprecated.
Creates a new instance of the Apache HTTP client that is used by the
ApacheHttpTransport() constructor. |
void |
shutdown()
Deprecated.
Shuts down the connection manager and releases allocated resources.
|
boolean |
supportsMethod(String method)
Deprecated.
Returns whether a specified HTTP method is supported by this transport.
|
createRequestFactory, createRequestFactory, isMtls
public ApacheHttpTransport()
newDefaultHttpClient()
for the Apache HTTP client.
Use ApacheHttpTransport.Builder
to modify HTTP client options.
public ApacheHttpTransport(org.apache.http.client.HttpClient httpClient)
Note that a few settings are overridden:
HttpProtocolParams.setVersion(org.apache.http.params.HttpParams, org.apache.http.ProtocolVersion)
with HttpVersion.HTTP_1_1
.
ClientPNames.HANDLE_REDIRECTS
.
ConnManagerParams.setTimeout(org.apache.http.params.HttpParams, long)
and HttpConnectionParams.setConnectionTimeout(org.apache.http.params.HttpParams, int)
are set on each request based on HttpRequest.getConnectTimeout()
.
HttpConnectionParams.setSoTimeout(org.apache.http.params.HttpParams, int)
is set on each request based on HttpRequest.getReadTimeout()
.
Use ApacheHttpTransport.Builder
for a more user-friendly way to modify the HTTP client options.
httpClient
- Apache HTTP client to usepublic static org.apache.http.impl.client.DefaultHttpClient newDefaultHttpClient()
ApacheHttpTransport()
constructor.
Use this constructor if you want to customize the default Apache HTTP client. Settings:
ThreadSafeClientConnManager
.
HttpConnectionParams.setSocketBufferSize(org.apache.http.params.HttpParams, int)
.
ProxySelectorRoutePlanner
with ProxySelector.getDefault()
, which uses the proxy settings from system
properties.
public boolean supportsMethod(String method)
HttpTransport
Default implementation returns true if and only if the request method is "DELETE"
,
"GET"
, "POST"
, or "PUT"
. Subclasses should override.
supportsMethod
in class HttpTransport
method
- HTTP methodprotected com.google.api.client.http.apache.ApacheHttpRequest buildRequest(String method, String url)
HttpTransport
buildRequest
in class HttpTransport
method
- HTTP methodurl
- URLpublic void shutdown()
shutdown
in class HttpTransport
public org.apache.http.client.HttpClient getHttpClient()
Copyright © 2011–2020 Google. All rights reserved.