content
null for none.Implementation is not thread-safe.
private BackOffPolicyprivate int0 for an infinite timeout.private HttpContentnull for none.private intexecute().private booleanstatic final intprivate HttpEncodingnull for none.private HttpExecuteInterceptorexecute() (before executing
the HTTP request) or null for none.private booleantrue by default).private HttpHeadersprivate HttpIOExceptionHandlernull for none.private booleanprivate int0 to not retry requests.private ObjectParserprivate int0 for an
infinite timeout.private Stringnull for none.private HttpHeadersprivate HttpResponseInterceptornull for none.private booleanprivate Sleeperprivate booleanUSER_AGENT_SUFFIX to the User-Agent header.private booleanexecute() on an HTTP error code (non-2XX)
after all retries and response handlers have been exhausted (true by default).private final HttpTransportprivate HttpUnsuccessfulResponseHandlernull for none.private GenericUrlstatic final Stringstatic final Stringexecute()Beta executeAsync(Executor) in a single separate
thread using Executors.newSingleThreadExecutor().executeAsync(Executor executor) Beta int0 for an infinite
timeout.null for none.intexecute().null for none.booleanexecute()
(before executing the HTTP request) or null for none.int0 to not retry requests.final ObjectParserObjectParser used to parse the response or null for none.int0
for an infinite timeout.null for none.null for none.booleansetIOExceptionHandler(HttpIOExceptionHandler) instead.booleanUSER_AGENT_SUFFIX to the User-Agent header.booleanexecute() on an HTTP error code
(non-2XX) after all retries and response handlers have been exhausted.null for none.getUrl()booleanhandleRedirect(int statusCode,
HttpHeaders responseHeaders) booleanbooleansetBackOffPolicy(BackOffPolicy backOffPolicy) setConnectTimeout(int connectTimeout) 0 for an infinite
timeout.setContent(HttpContent content) null for none.setContentLoggingLimit(int contentLoggingLimit) execute().setCurlLoggingEnabled(boolean curlLoggingEnabled) setEncoding(HttpEncoding encoding) null for none.setFollowRedirects(boolean followRedirects) setHeaders(HttpHeaders headers) setInterceptor(HttpExecuteInterceptor interceptor) execute() (before
executing the HTTP request) or null for none.setIOExceptionHandler(HttpIOExceptionHandler ioExceptionHandler) setLoggingEnabled(boolean loggingEnabled) setNumberOfRetries(int numRetries) 0 to not retry requests.setParser(ObjectParser parser) ObjectParser used to parse the response to this request or null for
none.setReadTimeout(int readTimeout) 0 for
an infinite timeout.setRequestMethod(String requestMethod) null for none.setResponseHeaders(HttpHeaders responseHeaders) setResponseInterceptor(HttpResponseInterceptor responseInterceptor) null for none.setRetryOnExecuteIOException(boolean retryOnExecuteIOException) setIOExceptionHandler(HttpIOExceptionHandler) instead.setSleeper(Sleeper sleeper) setSuppressUserAgentSuffix(boolean suppressUserAgentSuffix) USER_AGENT_SUFFIX to the User-Agent header.setThrowExceptionOnExecuteError(boolean throwExceptionOnExecuteError) execute() on a HTTP error code
(non-2XX) after all retries and response handlers have been exhausted.setUnsuccessfulResponseHandler(HttpUnsuccessfulResponseHandler unsuccessfulResponseHandler) null for none.setUrl(GenericUrl url)
Includes a "(gzip)" suffix in case the server -- as Google's servers may do -- checks
the User-Agent header to try to detect if the client accepts gzip-encoded responses.
execute() (before executing
the HTTP request) or null for none.
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;
}
0 to not retry requests. Retries occur as a result of either
HttpUnsuccessfulResponseHandler or HttpIOExceptionHandler which handles
abnormal HTTP response or the I/O exception.execute().
Content will only be logged if isLoggingEnabled() is true.
If the content size is greater than this limit then it will not be logged.
Can be set to 0 to disable content logging. This is useful for example if content has
sensitive data such as authentication information.
Defaults to 16KB.
true.null for none.null for none.0 for an infinite timeout.0 for an
infinite timeout.null for none.null for none.null for none.null for none.BackOffPolicy to use between retry attempts or null for none.true by default).execute() on an HTTP error code (non-2XX)
after all retries and response handlers have been exhausted (true by default).IOException is encountered in
LowLevelHttpRequest.execute().USER_AGENT_SUFFIX to the User-Agent header.
It is false by default.
transport - HTTP transportrequestMethod - HTTP request method or null for nonenull for none.null for none.null for none.setUnsuccessfulResponseHandler(HttpUnsuccessfulResponseHandler) with a new
HttpBackOffUnsuccessfulResponseHandler instead.setUnsuccessfulResponseHandler(HttpUnsuccessfulResponseHandler) with a new
HttpBackOffUnsuccessfulResponseHandler instead.execute().
If the content size is greater than this limit then it will not be logged.
Content will only be logged if isLoggingEnabled() is true.
Can be set to 0 to disable content logging. This is useful for example if content has
sensitive data such as authentication information.
Defaults to 16KB.
execute().
If the content size is greater than this limit then it will not be logged.
Content will only be logged if isLoggingEnabled() is true.
Can be set to 0 to disable content logging. This is useful for example if content has
sensitive data such as authentication information.
Defaults to 16KB.
Defaults to true.
Defaults to true.
Defaults to true.
0 for an infinite
timeout.0 for an infinite
timeout.
By default it is 20000 (20 seconds).
0
for an infinite timeout.
By default it is 20000 (20 seconds).
0 for
an infinite timeout.
By default, this is a new unmodified instance of HttpHeaders.
By default, this is a new unmodified instance of HttpHeaders.
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;
}
execute()
(before executing the HTTP request) or null for none.execute() (before
executing the HTTP request) or null for none.null for none.null for none.null for none.null for none.0 to not retry requests. Retries occur as a result of either
HttpUnsuccessfulResponseHandler or HttpIOExceptionHandler which handles
abnormal HTTP response or the I/O exception.0 to not retry requests. Retries occur as a result of either
HttpUnsuccessfulResponseHandler or HttpIOExceptionHandler which handles
abnormal HTTP response or the I/O exception.
The default value is DEFAULT_NUMBER_OF_RETRIES.
ObjectParser used to parse the response to this request or null for
none.
This parser will be preferred over any registered HttpParser.
ObjectParser used to parse the response or null for none.
The default value is true.
execute() on an HTTP error code
(non-2XX) after all retries and response handlers have been exhausted.execute() on a HTTP error code
(non-2XX) after all retries and response handlers have been exhausted.
The default value is true.
setIOExceptionHandler(HttpIOExceptionHandler) instead.Beta IOException is encountered in
LowLevelHttpRequest.execute().setIOExceptionHandler(HttpIOExceptionHandler) instead.Beta IOException is encountered in
LowLevelHttpRequest.execute().
The default value is false.
USER_AGENT_SUFFIX to the User-Agent header.USER_AGENT_SUFFIX to the User-Agent header.
The default value is false.
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.
Note that when calling to this method twice or more, the state of this HTTP request object
isn't cleared, so the request will continue where it was left. For example, the state of the
HttpUnsuccessfulResponseHandler attached to this HTTP request will remain the same as
it was left after last execute.
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.
Callers should call HttpResponse.disconnect() when the returned HTTP response object is
no longer needed. However, HttpResponse.disconnect() does not have to be called if the
response stream is properly closed. Example usage:
HttpResponse response = request.execute();
try {
// process the HTTP response object
} finally {
response.disconnect();
}
getThrowExceptionOnExecuteError() is false)HttpResponseException - for an HTTP error response (only if
getThrowExceptionOnExecuteError() is true)IOExceptionBeta executor - executor to run the asynchronous requestBeta executeAsync(Executor) in a single separate
thread using Executors.newSingleThreadExecutor().
When the status code is 303 the method on the request is changed to a GET as per the
RFC2616 specification. On a redirect, it also removes the "Authorization" and all
"If-*" request headers.
Upgrade warning: When handling a status code of 303, handleRedirect(int, HttpHeaders)
now correctly removes any content from the body of the new request, as GET requests should not
have content. It did not do this in prior version 1.16.
Sleeper.DEFAULT.