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 for
ApacheHttpTransport.
|
| Constructor and Description |
|---|
ApacheHttpTransport()
Constructor that uses
newDefaultHttpClient() for the Apache HTTP client.
|
ApacheHttpTransport(org
Constructor that allows an alternative Apache HTTP client to be used.
|
| Modifier and Type | Method and Description |
|---|---|
protected com |
buildRequest(String
Builds a low level HTTP request for the given HTTP method.
|
org |
getHttpClient()
Returns the Apache HTTP client.
|
static org |
newDefaultHttpClient()
Creates a new instance of the Apache HTTP client that is used by the
ApacheHttpTransport() constructor.
|
void |
shutdown()
Shuts down the connection manager and releases allocated resources.
|
boolean |
supportsMethod(String
Returns whether a specified HTTP method is supported by this transport.
|
createRequestFactory, createRequestFactorypublic 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 use
public 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(Stringmethod)
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 method
protected com.api .client .http .apache .ApacheHttpRequest buildRequest(String method, String url)
HttpTransport
buildRequest in class
HttpTransport
method - HTTP method
url - URL
public void shutdown()
shutdown in class
HttpTransport
public org.apache .http .client .HttpClient getHttpClient()