public final class HttpRequestFactory
Thread-safe light-weight HTTP request factory layer on top of the HTTP transport that has an optional HTTP request initializer for initializing requests.
For example, to use a particular authorization header across all requests, use:
public static HttpRequestFactory createRequestFactory(HttpTransport transport) { return transport.createRequestFactory(new HttpRequestInitializer() { public void initialize(HttpRequest request) throws IOException { request.getHeaders().setAuthorization("..."); } }); }
Methods
buildDeleteRequest(GenericUrl url)
public HttpRequest buildDeleteRequest(GenericUrl url)
Builds a DELETE
request for the given URL.
Name | Description |
url | GenericUrl HTTP request URL or |
Type | Description |
HttpRequest | new HTTP request |
Type | Description |
IOException |
buildGetRequest(GenericUrl url)
public HttpRequest buildGetRequest(GenericUrl url)
Builds a GET
request for the given URL.
Name | Description |
url | GenericUrl HTTP request URL or |
Type | Description |
HttpRequest | new HTTP request |
Type | Description |
IOException |
buildHeadRequest(GenericUrl url)
public HttpRequest buildHeadRequest(GenericUrl url)
Builds a HEAD
request for the given URL.
Name | Description |
url | GenericUrl HTTP request URL or |
Type | Description |
HttpRequest | new HTTP request |
Type | Description |
IOException |
buildPatchRequest(GenericUrl url, HttpContent content)
public HttpRequest buildPatchRequest(GenericUrl url, HttpContent content)
Builds a PATCH
request for the given URL and content.
Name | Description |
url | GenericUrl HTTP request URL or |
content | HttpContent HTTP request content or |
Type | Description |
HttpRequest | new HTTP request |
Type | Description |
IOException |
buildPostRequest(GenericUrl url, HttpContent content)
public HttpRequest buildPostRequest(GenericUrl url, HttpContent content)
Builds a POST
request for the given URL and content.
Name | Description |
url | GenericUrl HTTP request URL or |
content | HttpContent HTTP request content or |
Type | Description |
HttpRequest | new HTTP request |
Type | Description |
IOException |
buildPutRequest(GenericUrl url, HttpContent content)
public HttpRequest buildPutRequest(GenericUrl url, HttpContent content)
Builds a PUT
request for the given URL and content.
Name | Description |
url | GenericUrl HTTP request URL or |
content | HttpContent HTTP request content or |
Type | Description |
HttpRequest | new HTTP request |
Type | Description |
IOException |
buildRequest(String requestMethod, GenericUrl url, HttpContent content)
public HttpRequest buildRequest(String requestMethod, GenericUrl url, HttpContent content)
Builds a request for the given HTTP method, URL, and content.
Name | Description |
requestMethod | String HTTP request method |
url | GenericUrl HTTP request URL or |
content | HttpContent HTTP request content or |
Type | Description |
HttpRequest | new HTTP request |
Type | Description |
IOException |
getInitializer()
public HttpRequestInitializer getInitializer()
Returns the HTTP request initializer or null
for none.
This initializer is invoked before setting its method, URL, or content.
Type | Description |
HttpRequestInitializer |
getTransport()
public HttpTransport getTransport()
Returns the HTTP transport.
Type | Description |
HttpTransport |