Class HttpRequestFactory
java.lang.Object
com.google.api.client.http.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("...");
}
});
}
- Since:
- 1.4
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final HttpRequestInitializerHTTP request initializer ornullfor none.private final HttpTransportHTTP transport. -
Constructor Summary
ConstructorsConstructorDescriptionHttpRequestFactory(HttpTransport transport, HttpRequestInitializer initializer) -
Method Summary
Modifier and TypeMethodDescriptionBuilds aDELETErequest for the given URL.Builds aGETrequest for the given URL.Builds aHEADrequest for the given URL.buildPatchRequest(GenericUrl url, HttpContent content) Builds aPATCHrequest for the given URL and content.buildPostRequest(GenericUrl url, HttpContent content) Builds aPOSTrequest for the given URL and content.buildPutRequest(GenericUrl url, HttpContent content) Builds aPUTrequest for the given URL and content.buildRequest(String requestMethod, GenericUrl url, HttpContent content) Builds a request for the given HTTP method, URL, and content.Returns the HTTP request initializer ornullfor none.Returns the HTTP transport.
-
Field Details
-
transport
HTTP transport. -
initializer
HTTP request initializer ornullfor none.
-
-
Constructor Details
-
HttpRequestFactory
HttpRequestFactory(HttpTransport transport, HttpRequestInitializer initializer) - Parameters:
transport- HTTP transportinitializer- HTTP request initializer ornullfor none
-
-
Method Details
-
getTransport
-
getInitializer
Returns the HTTP request initializer ornullfor none.This initializer is invoked before setting its method, URL, or content.
- Since:
- 1.5
-
buildRequest
public HttpRequest buildRequest(String requestMethod, GenericUrl url, HttpContent content) throws IOException Builds a request for the given HTTP method, URL, and content.- Parameters:
requestMethod- HTTP request methodurl- HTTP request URL ornullfor nonecontent- HTTP request content ornullfor none- Returns:
- new HTTP request
- Throws:
IOException- Since:
- 1.12
-
buildDeleteRequest
Builds aDELETErequest for the given URL.- Parameters:
url- HTTP request URL ornullfor none- Returns:
- new HTTP request
- Throws:
IOException
-
buildGetRequest
Builds aGETrequest for the given URL.- Parameters:
url- HTTP request URL ornullfor none- Returns:
- new HTTP request
- Throws:
IOException
-
buildPostRequest
Builds aPOSTrequest for the given URL and content.- Parameters:
url- HTTP request URL ornullfor nonecontent- HTTP request content ornullfor none- Returns:
- new HTTP request
- Throws:
IOException
-
buildPutRequest
Builds aPUTrequest for the given URL and content.- Parameters:
url- HTTP request URL ornullfor nonecontent- HTTP request content ornullfor none- Returns:
- new HTTP request
- Throws:
IOException
-
buildPatchRequest
Builds aPATCHrequest for the given URL and content.- Parameters:
url- HTTP request URL ornullfor nonecontent- HTTP request content ornullfor none- Returns:
- new HTTP request
- Throws:
IOException
-
buildHeadRequest
Builds aHEADrequest for the given URL.- Parameters:
url- HTTP request URL ornullfor none- Returns:
- new HTTP request
- Throws:
IOException
-