public abstract class HttpTransport extends Object
Implementation is thread-safe, and sub-classes must be thread-safe. For maximum efficiency, applications should use a single globally-shared instance of the HTTP transport.
The recommended concrete implementation HTTP transport library to use depends on what environment you are running in:
com.google.api.client.apache.ApacheHttpTransportdoesn't work on App Engine because the Apache HTTP Client opens its own sockets (though in theory there are ways to hack it to work on App Engine that might work).
com.google.api.client.javanet.NetHttpTransportis discouraged due to a bug in the App Engine SDK itself in how it parses HTTP headers in the response.
com.google.api.client.extensions.android.http.AndroidHttp(read its JavaDoc for details).
com.google.api.client.javanet.NetHttpTransportis based on the HttpURLConnection built into the Java SDK, so it is normally the preferred choice.
com.google.api.client.apache.ApacheHttpTransportis a good choice for users of the Apache HTTP Client, especially if you need some of the configuration options available in that library.
Some HTTP transports do not support all HTTP methods. Use
check if a certain HTTP method is supported. Calling
buildRequest() on a method that is
not supported will result in an
|Constructor and Description|
|Modifier and Type||Method and Description|
Builds a low level HTTP request for the given HTTP method.
Returns a new instance of an HTTP request factory based on this HTTP transport.
Returns a new instance of an HTTP request factory based on this HTTP transport with the given HTTP request initializer.
Default implementation does nothing, but subclasses may override to possibly release allocated system resources or close connections.
Returns whether a specified HTTP method is supported by this transport.
public final HttpRequestFactory createRequestFactory()
public final HttpRequestFactory createRequestFactory(HttpRequestInitializer initializer)
initializer- HTTP request initializer or
public boolean supportsMethod(String method) throws IOException
Default implementation returns true if and only if the request method is
"PUT". Subclasses should override.
method- HTTP method
IOException- I/O exception
protected abstract LowLevelHttpRequest buildRequest(String method, String url) throws IOException
Copyright © 2011-2015 Google. All Rights Reserved.