T
- type of the responsepublic abstract class AbstractGoogleClientRequest<T>
extends com.google.api.client.util.GenericData
AbstractGoogleClient
.
Implementation is not thread-safe.
com.google.api.client.util.GenericData.Flags
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
USER_AGENT_SUFFIX
User agent suffix for all requests.
|
Modifier | Constructor and Description |
---|---|
protected |
AbstractGoogleClientRequest(AbstractGoogleClient abstractGoogleClient,
java.lang.String requestMethod,
java.lang.String uriTemplate,
com.google.api.client.http.HttpContent httpContent,
java.lang.Class<T> responseClass) |
Modifier and Type | Method and Description |
---|---|
com.google.api.client.http.HttpRequest |
buildHttpRequest()
Create a request suitable for use against this service.
|
com.google.api.client.http.GenericUrl |
buildHttpRequestUrl()
Creates a new instance of
GenericUrl suitable for use against this service. |
protected com.google.api.client.http.HttpRequest |
buildHttpRequestUsingHead()
Create a request suitable for use against this service, but using HEAD instead of GET.
|
protected void |
checkRequiredParameter(java.lang.Object value,
java.lang.String name)
Ensures that the specified required parameter is not null or
AbstractGoogleClient.getSuppressRequiredParameterChecks() is true. |
T |
execute()
Sends the metadata request to the server and returns the parsed metadata response.
|
void |
executeAndDownloadTo(java.io.OutputStream outputStream)
Sends the metadata request to the server and writes the metadata content input stream of
HttpResponse into the given destination output stream. |
java.io.InputStream |
executeAsInputStream()
Sends the metadata request to the server and returns the metadata content input stream of
HttpResponse . |
protected com.google.api.client.http.HttpResponse |
executeMedia()
Sends the media request to the server and returns the raw media
HttpResponse . |
protected void |
executeMediaAndDownloadTo(java.io.OutputStream outputStream)
Sends the media request to the server and writes the media content input stream of
HttpResponse into the given destination output stream. |
protected java.io.InputStream |
executeMediaAsInputStream()
Sends the media request to the server and returns the media content input stream of
HttpResponse . |
com.google.api.client.http.HttpResponse |
executeUnparsed()
Sends the metadata request to the server and returns the raw metadata
HttpResponse . |
protected com.google.api.client.http.HttpResponse |
executeUsingHead()
Sends the metadata request using HEAD to the server and returns the raw metadata
HttpResponse for the response headers. |
AbstractGoogleClient |
getAbstractGoogleClient()
Returns the Google client.
|
boolean |
getDisableGZipContent()
Returns whether to disable GZip compression of HTTP content.
|
com.google.api.client.http.HttpContent |
getHttpContent()
Returns the HTTP content or
null for none. |
com.google.api.client.http.HttpHeaders |
getLastResponseHeaders()
Returns the HTTP headers of the last response or
null before request has been executed. |
int |
getLastStatusCode()
Returns the status code of the last response or
-1 before request has been executed. |
java.lang.String |
getLastStatusMessage()
Returns the status message of the last response or
null before request has been
executed. |
MediaHttpDownloader |
getMediaHttpDownloader()
Returns the media HTTP downloader or
null for none. |
MediaHttpUploader |
getMediaHttpUploader()
Returns the media HTTP Uploader or
null for none. |
com.google.api.client.http.HttpHeaders |
getRequestHeaders()
Returns the HTTP headers used for the Google client request.
|
java.lang.String |
getRequestMethod()
Returns the HTTP method.
|
java.lang.Class<T> |
getResponseClass()
Returns the response class to parse into.
|
java.lang.String |
getUriTemplate()
Returns the URI template for the path relative to the base URL.
|
protected void |
initializeMediaDownload()
Initializes the media HTTP downloader.
|
protected void |
initializeMediaUpload(com.google.api.client.http.AbstractInputStreamContent mediaContent)
Initializes the media HTTP uploader based on the media content.
|
protected java.io.IOException |
newExceptionOnError(com.google.api.client.http.HttpResponse response)
Returns the exception to throw on an HTTP error response as defined by
HttpResponse.isSuccessStatusCode() . |
<E> void |
queue(BatchRequest batchRequest,
java.lang.Class<E> errorClass,
BatchCallback<T,E> callback)
Queues the request into the specified batch request container using the specified error class.
|
AbstractGoogleClientRequest<T> |
set(java.lang.String fieldName,
java.lang.Object value) |
AbstractGoogleClientRequest<T> |
setDisableGZipContent(boolean disableGZipContent)
Sets whether to disable GZip compression of HTTP content.
|
AbstractGoogleClientRequest<T> |
setRequestHeaders(com.google.api.client.http.HttpHeaders headers)
Sets the HTTP headers used for the Google client request.
|
clone, entrySet, get, getClassInfo, getUnknownKeys, put, putAll, remove, setUnknownKeys
public static final java.lang.String USER_AGENT_SUFFIX
protected AbstractGoogleClientRequest(AbstractGoogleClient abstractGoogleClient, java.lang.String requestMethod, java.lang.String uriTemplate, com.google.api.client.http.HttpContent httpContent, java.lang.Class<T> responseClass)
abstractGoogleClient
- Google clientrequestMethod
- HTTP MethoduriTemplate
- URI template for the path relative to the base URL. If it starts with a "/"
the base path from the base URL will be stripped out. The URI template can also be a
full URL. URI template expansion is done using
UriTemplate.expand(String, String, Object, boolean)
httpContent
- HTTP content or null
for noneresponseClass
- response class to parse intopublic final boolean getDisableGZipContent()
public AbstractGoogleClientRequest<T> setDisableGZipContent(boolean disableGZipContent)
By default it is false
.
Overriding is only supported for the purpose of calling the super implementation and changing the return type, but nothing else.
public final java.lang.String getRequestMethod()
public final java.lang.String getUriTemplate()
public final com.google.api.client.http.HttpContent getHttpContent()
null
for none.public AbstractGoogleClient getAbstractGoogleClient()
Overriding is only supported for the purpose of calling the super implementation and changing the return type, but nothing else.
public final com.google.api.client.http.HttpHeaders getRequestHeaders()
public AbstractGoogleClientRequest<T> setRequestHeaders(com.google.api.client.http.HttpHeaders headers)
These headers are set on the request after buildHttpRequest()
is called, this means that
HttpRequestInitializer.initialize(com.google.api.client.http.HttpRequest)
is called first.
Overriding is only supported for the purpose of calling the super implementation and changing the return type, but nothing else.
public final com.google.api.client.http.HttpHeaders getLastResponseHeaders()
null
before request has been executed.public final int getLastStatusCode()
-1
before request has been executed.public final java.lang.String getLastStatusMessage()
null
before request has been
executed.public final java.lang.Class<T> getResponseClass()
public final MediaHttpUploader getMediaHttpUploader()
null
for none.protected final void initializeMediaUpload(com.google.api.client.http.AbstractInputStreamContent mediaContent)
mediaContent
- media contentpublic final MediaHttpDownloader getMediaHttpDownloader()
null
for none.protected final void initializeMediaDownload()
public com.google.api.client.http.GenericUrl buildHttpRequestUrl()
GenericUrl
suitable for use against this service.
Subclasses may override by calling the super implementation.
GenericUrl
public com.google.api.client.http.HttpRequest buildHttpRequest() throws java.io.IOException
Subclasses may override by calling the super implementation.
java.io.IOException
protected com.google.api.client.http.HttpRequest buildHttpRequestUsingHead() throws java.io.IOException
Only supported when the original request method is GET.
Subclasses may override by calling the super implementation.
java.io.IOException
public com.google.api.client.http.HttpResponse executeUnparsed() throws java.io.IOException
HttpResponse
.
Callers are responsible for disconnecting the HTTP response by calling
HttpResponse.disconnect()
. Example usage:
HttpResponse response = request.executeUnparsed(); try { // process response.. } finally { response.disconnect(); }
Subclasses may override by calling the super implementation.
HttpResponse
java.io.IOException
protected com.google.api.client.http.HttpResponse executeMedia() throws java.io.IOException
HttpResponse
.
Callers are responsible for disconnecting the HTTP response by calling
HttpResponse.disconnect()
. Example usage:
HttpResponse response = request.executeMedia(); try { // process response.. } finally { response.disconnect(); }
Subclasses may override by calling the super implementation.
HttpResponse
java.io.IOException
protected com.google.api.client.http.HttpResponse executeUsingHead() throws java.io.IOException
HttpResponse
for the response headers.
Only supported when the original request method is GET. The response content is assumed to be
empty and ignored. Calls HttpResponse.ignore()
so there is no need to disconnect the
response. Example usage:
HttpResponse response = request.executeUsingHead(); // look at response.getHeaders()
Subclasses may override by calling the super implementation.
HttpResponse
java.io.IOException
protected java.io.IOException newExceptionOnError(com.google.api.client.http.HttpResponse response)
HttpResponse.isSuccessStatusCode()
.
It is guaranteed that HttpResponse.isSuccessStatusCode()
is false
. Default
implementation is to call HttpResponseException.HttpResponseException(HttpResponse)
,
but subclasses may override.
response
- HTTP responsepublic T execute() throws java.io.IOException
Subclasses may override by calling the super implementation.
java.io.IOException
public java.io.InputStream executeAsInputStream() throws java.io.IOException
HttpResponse
.
Callers are responsible for closing the input stream after it is processed. Example sample:
InputStream is = request.executeAsInputStream(); try { // Process input stream.. } finally { is.close(); }
Subclasses may override by calling the super implementation.
java.io.IOException
protected java.io.InputStream executeMediaAsInputStream() throws java.io.IOException
HttpResponse
.
Callers are responsible for closing the input stream after it is processed. Example sample:
InputStream is = request.executeMediaAsInputStream(); try { // Process input stream.. } finally { is.close(); }
Subclasses may override by calling the super implementation.
java.io.IOException
public void executeAndDownloadTo(java.io.OutputStream outputStream) throws java.io.IOException
HttpResponse
into the given destination output stream.
This method closes the content of the HTTP response from HttpResponse.getContent()
.
Subclasses may override by calling the super implementation.
outputStream
- destination output streamjava.io.IOException
protected void executeMediaAndDownloadTo(java.io.OutputStream outputStream) throws java.io.IOException
HttpResponse
into the given destination output stream.
This method closes the content of the HTTP response from HttpResponse.getContent()
.
Subclasses may override by calling the super implementation.
outputStream
- destination output streamjava.io.IOException
public final <E> void queue(BatchRequest batchRequest, java.lang.Class<E> errorClass, BatchCallback<T,E> callback) throws java.io.IOException
Batched requests are then executed when BatchRequest.execute()
is called.
batchRequest
- batch request containererrorClass
- data class the unsuccessful response will be parsed into or
Void.class
to ignore the contentcallback
- batch callbackjava.io.IOException
public AbstractGoogleClientRequest<T> set(java.lang.String fieldName, java.lang.Object value)
set
in class com.google.api.client.util.GenericData
protected final void checkRequiredParameter(java.lang.Object value, java.lang.String name)
AbstractGoogleClient.getSuppressRequiredParameterChecks()
is true.value
- the value of the required parametername
- the name of the required parameterjava.lang.IllegalArgumentException
- if the specified required parameter is null and
AbstractGoogleClient.getSuppressRequiredParameterChecks()
is falseCopyright © 2010-2018 Google. All Rights Reserved.