|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.google.api.client.http.HttpRequest
public final class HttpRequest
HTTP request.
| Field Summary | |
|---|---|
int |
connectTimeout
Timeout in milliseconds to establish a connection or 0 for an infinite timeout. |
HttpContent |
content
HTTP request content or null for none. |
boolean |
disableContentLogging
Whether to disable request content logging during execute() (unless Level.ALL
is loggable which forces all logging). |
boolean |
enableGZipContent
Whether to enable gzip compression of HTTP content ( false by default). |
HttpHeaders |
headers
HTTP request headers. |
HttpExecuteInterceptor |
interceptor
HTTP request execute interceptor to intercept the start of execute() (before executing
the HTTP request) or null for none. |
HttpMethod |
method
HTTP request method. |
int |
numRetries
Set the number of retries that will be allowed to execute as the result of an HttpUnsuccessfulResponseHandler before being terminated or 0 to not retry
requests. |
int |
readTimeout
Timeout in milliseconds to read data from an established connection or 0 for an
infinite timeout. |
HttpHeaders |
responseHeaders
HTTP response headers. |
HttpTransport |
transport
HTTP transport. |
HttpUnsuccessfulResponseHandler |
unsuccessfulResponseHandler
HTTP unsuccessful (non-2XX) response handler. |
GenericUrl |
url
HTTP request URL. |
static String |
USER_AGENT_SUFFIX
User agent suffix for all requests. |
| Method Summary | |
|---|---|
void |
addParser(HttpParser parser)
Adds an HTTP response content parser. |
HttpResponse |
execute()
Execute the HTTP request and returns the HTTP response. |
HttpParser |
getParser(String contentType)
Returns the HTTP response content parser to use for the given content type or null if
none is defined. |
static String |
normalizeMediaType(String mediaType)
Returns the normalized media type without parameters of the form type "/" subtype" as
specified in Media Types. |
void |
setUrl(String encodedUrl)
Deprecated. (scheduled to be removed in 1.5) Use GenericUrl.GenericUrl(String) |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final String USER_AGENT_SUFFIX
public HttpExecuteInterceptor interceptor
execute() (before executing
the HTTP request) or null for none.
public HttpHeaders headers
For backwards compatibility, its value is initialized by calling clone() on the
HttpTransport.defaultHeaders, which by default is an instance of HttpHeaders.
public HttpHeaders responseHeaders
For example, this can be used if you want to use a subclass of HttpHeaders called
MyHeaders to process the response:
static String executeAndGetValueOfSomeCustomHeader(HttpRequest request) {
MyHeaders responseHeaders = new MyHeaders();
request.responseHeaders = responseHeaders;
HttpResponse response = request.execute();
return responseHeaders.someCustomHeader;
}
For backwards compatibility, its value is initialized by calling clone() on the
HttpTransport.defaultHeaders, which by default is an instance of HttpHeaders.
public int numRetries
HttpUnsuccessfulResponseHandler before being terminated or 0 to not retry
requests. The default value is 10.
public boolean disableContentLogging
execute() (unless Level.ALL
is loggable which forces all logging).
Useful for example if content has sensitive data such as an authentication information.
Defaults to false.
public HttpContent content
null for none.
public final HttpTransport transport
public HttpMethod method
public GenericUrl url
public int connectTimeout
0 for an infinite timeout.
By default it is 20 seconds.
public int readTimeout
0 for an
infinite timeout.
By default it is 20 seconds.
public HttpUnsuccessfulResponseHandler unsuccessfulResponseHandler
public boolean enableGZipContent
false by default).
Upgrade warning: in prior version 1.3, gzip compression was enabled whenever the content length was >= 256 bytes, the content type was text-based ("text/*" or "application/*"), and there was no encoding defined. With version 1.4, the decision is entirely based on this field.
| Method Detail |
|---|
@Deprecated public void setUrl(String encodedUrl)
GenericUrl.GenericUrl(String)
url based on the given encoded URL string.
public void addParser(HttpParser parser)
If there is already a previous parser defined for this new parser (as defined by
getParser(String) then the previous parser will be removed.
public final HttpParser getParser(String contentType)
null if
none is defined.
contentType - content type or null for null result
null for null input
public HttpResponse execute()
throws IOException
Note that regardless of the returned status code, the HTTP response content has not been parsed yet, and must be parsed by the calling code.
Almost all details of the request and response are logged if Level.CONFIG is loggable.
The only exception is the value of the Authorization header which is only logged if
Level.ALL is loggable.
HttpResponseException - for an HTTP error code
IOExceptionHttpResponse.isSuccessStatusCodepublic static String normalizeMediaType(String mediaType)
type "/" subtype" as
specified in Media Types.
mediaType - unnormalized media type with possible parameters or null for null result
null for null input
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||