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
Builder for
ApacheHttpTransport. |
| Constructor and Description |
|---|
ApacheHttpTransport()
Constructor that uses
newDefaultHttpClient() for the Apache HTTP client. |
ApacheHttpTransport(org.apache.http.client.HttpClient httpClient)
Constructor that allows an alternative Apache HTTP client to be used.
|
| Modifier and Type | Method and Description |
|---|---|
com.google.api.client.http.apache.ApacheHttpRequest |
buildDeleteRequest(String url)
Deprecated.
|
com.google.api.client.http.apache.ApacheHttpRequest |
buildGetRequest(String url)
Deprecated.
|
com.google.api.client.http.apache.ApacheHttpRequest |
buildHeadRequest(String url)
Deprecated.
|
com.google.api.client.http.apache.ApacheHttpRequest |
buildPatchRequest(String url)
Deprecated.
|
com.google.api.client.http.apache.ApacheHttpRequest |
buildPostRequest(String url)
Deprecated.
|
com.google.api.client.http.apache.ApacheHttpRequest |
buildPutRequest(String url)
Deprecated.
|
protected com.google.api.client.http.apache.ApacheHttpRequest |
buildRequest(String method,
String url)
Builds a low level HTTP request for the given HTTP method.
|
org.apache.http.client.HttpClient |
getHttpClient()
Returns the Apache HTTP client.
|
static org.apache.http.impl.client.DefaultHttpClient |
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 |
supportsHead()
Deprecated.
|
boolean |
supportsMethod(String method)
Returns whether a specified HTTP method is supported by this transport.
|
boolean |
supportsPatch()
Deprecated.
|
createRequestFactory, createRequestFactorypublic ApacheHttpTransport()
newDefaultHttpClient() for the Apache HTTP client.
Use ApacheHttpTransport.Builder to modify HTTP client options.
Upgrade warning: in prior version 1.12 the route planner was DefaultHttpRoutePlanner
but starting with version 1.13 the route planner is ProxySelectorRoutePlanner.
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.
Upgrade warning: in prior version 1.12 the route planner was DefaultHttpRoutePlanner
but starting with version 1.13 the route planner is ProxySelectorRoutePlanner.
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 HttpTransportmethod - HTTP methodprotected com.google.api.client.http.apache.ApacheHttpRequest buildRequest(String method, String url)
HttpTransport
Warning: for backwards compatibility, in version 1.12 a default implementation that throws an
IllegalArgumentException is provided, but it will be made abstract in the next version
1.13.
buildRequest in class HttpTransportmethod - HTTP methodurl - URL@Deprecated public boolean supportsHead()
HttpTransportHEAD request method.
Default implementation calls HttpTransport.supportsMethod(java.lang.String).
Upgrade warning: this method now throws an IOException. In prior version 1.11 it did
not throw an exception.
supportsHead in class HttpTransport@Deprecated public boolean supportsPatch()
HttpTransportPATCH request method.
Default implementation calls HttpTransport.supportsMethod(java.lang.String).
Upgrade warning: this method now throws an IOException. In prior version 1.11 it did
not throw an exception.
supportsPatch in class HttpTransport@Deprecated public com.google.api.client.http.apache.ApacheHttpRequest buildDeleteRequest(String url)
HttpTransportDELETE request.
Default implementation calls HttpTransport.buildRequest().
buildDeleteRequest in class HttpTransporturl - URL@Deprecated public com.google.api.client.http.apache.ApacheHttpRequest buildGetRequest(String url)
HttpTransportGET request.
Default implementation calls HttpTransport.buildRequest().
buildGetRequest in class HttpTransporturl - URL@Deprecated public com.google.api.client.http.apache.ApacheHttpRequest buildHeadRequest(String url)
HttpTransportHEAD request.
Won't be called if HttpTransport.supportsHead() returns false.
Default implementation calls HttpTransport.buildRequest().
Upgrade warning: in prior version it threw an UnsupportedOperationException by
default}.
buildHeadRequest in class HttpTransporturl - URL@Deprecated public com.google.api.client.http.apache.ApacheHttpRequest buildPatchRequest(String url)
HttpTransportPATCH request.
Won't be called if HttpTransport.supportsPatch() returns false.
Default implementation calls HttpTransport.buildRequest().
Upgrade warning: in prior version it threw an UnsupportedOperationException by
default}.
buildPatchRequest in class HttpTransporturl - URL@Deprecated public com.google.api.client.http.apache.ApacheHttpRequest buildPostRequest(String url)
HttpTransportPOST request.
Default implementation calls HttpTransport.buildRequest().
buildPostRequest in class HttpTransporturl - URL@Deprecated public com.google.api.client.http.apache.ApacheHttpRequest buildPutRequest(String url)
HttpTransportPUT request.
Default implementation calls HttpTransport.buildRequest().
buildPutRequest in class HttpTransporturl - URLpublic void shutdown()
shutdown in class HttpTransportpublic org.apache.http.client.HttpClient getHttpClient()
Copyright © 2011-2012 Google. All Rights Reserved.