com.google.api.client.http
Class HttpTransport

java.lang.Object
  extended by com.google.api.client.http.HttpTransport
Direct Known Subclasses:
ApacheHttpTransport, MockHttpTransport, NetHttpTransport

public abstract class HttpTransport
extends Object

Thread-safe abstract HTTP transport.

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:

Since:
1.0
Author:
Yaniv Inbar

Constructor Summary
HttpTransport()
           
 
Method Summary
protected abstract  LowLevelHttpRequest buildDeleteRequest(String url)
          Builds a DELETE request.
protected abstract  LowLevelHttpRequest buildGetRequest(String url)
          Builds a GET request.
protected  LowLevelHttpRequest buildHeadRequest(String url)
          Builds a HEAD request.
protected  LowLevelHttpRequest buildPatchRequest(String url)
          Builds a PATCH request.
protected abstract  LowLevelHttpRequest buildPostRequest(String url)
          Builds a POST request.
protected abstract  LowLevelHttpRequest buildPutRequest(String url)
          Builds a PUT request.
 HttpRequestFactory createRequestFactory()
          Returns a new instance of an HTTP request factory based on this HTTP transport.
 HttpRequestFactory createRequestFactory(HttpRequestInitializer initializer)
          Returns a new instance of an HTTP request factory based on this HTTP transport with the given HTTP request initializer.
 void shutdown()
          Default implementation does nothing, but subclasses may override to possibly release allocated system resources or close connections.
 boolean supportsHead()
          Returns whether this HTTP transport implementation supports the HEAD request method.
 boolean supportsPatch()
          Returns whether this HTTP transport implementation supports the PATCH request method.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HttpTransport

public HttpTransport()
Method Detail

createRequestFactory

public final HttpRequestFactory createRequestFactory()
Returns a new instance of an HTTP request factory based on this HTTP transport.

Returns:
new instance of an HTTP request factory
Since:
1.4

createRequestFactory

public final HttpRequestFactory createRequestFactory(HttpRequestInitializer initializer)
Returns a new instance of an HTTP request factory based on this HTTP transport with the given HTTP request initializer.

Parameters:
initializer - HTTP request initializer or null for none
Returns:
new instance of an HTTP request factory
Since:
1.4

supportsHead

public boolean supportsHead()
Returns whether this HTTP transport implementation supports the HEAD request method.

Default implementation returns false.

Since:
1.3

supportsPatch

public boolean supportsPatch()
Returns whether this HTTP transport implementation supports the PATCH request method.

Default implementation returns false.

Since:
1.3

buildDeleteRequest

protected abstract LowLevelHttpRequest buildDeleteRequest(String url)
                                                   throws IOException
Builds a DELETE request.

Parameters:
url - URL
Throws:
IOException - I/O exception
Since:
1.3

buildGetRequest

protected abstract LowLevelHttpRequest buildGetRequest(String url)
                                                throws IOException
Builds a GET request.

Parameters:
url - URL
Throws:
IOException - I/O exception
Since:
1.3

buildHeadRequest

protected LowLevelHttpRequest buildHeadRequest(String url)
                                        throws IOException
Builds a HEAD request. Won't be called if supportsHead() returns false .

Default implementation throws an UnsupportedOperationException.

Parameters:
url - URL
Throws:
IOException - I/O exception
Since:
1.3

buildPatchRequest

protected LowLevelHttpRequest buildPatchRequest(String url)
                                         throws IOException
Builds a PATCH request. Won't be called if supportsPatch() returns false.

Default implementation throws an UnsupportedOperationException.

Parameters:
url - URL
Throws:
IOException - I/O exception
Since:
1.3

buildPostRequest

protected abstract LowLevelHttpRequest buildPostRequest(String url)
                                                 throws IOException
Builds a POST request.

Parameters:
url - URL
Throws:
IOException - I/O exception
Since:
1.3

buildPutRequest

protected abstract LowLevelHttpRequest buildPutRequest(String url)
                                                throws IOException
Builds a PUT request.

Parameters:
url - URL
Throws:
IOException - I/O exception
Since:
1.3

shutdown

public void shutdown()
              throws IOException
Default implementation does nothing, but subclasses may override to possibly release allocated system resources or close connections.

Throws:
IOException - I/O exception
Since:
1.4


Copyright © 2011 Google. All Rights Reserved.