public interface URLFetchService
URLFetchService
provides a way for user code to execute
HTTP requests to external URLs.
Chunked and hanging requests are not supported, and all content will be returned in a single block.
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
DEFAULT_DEADLINE_PROPERTY
System property for defining a global default URLFetch deadline.
|
Modifier and Type | Method and Description |
---|---|
HTTPResponse |
fetch(HTTPRequest request)
Execute the specified request and return its response.
|
HTTPResponse |
fetch(java.net.URL url)
Convenience method for retrieving a specific URL via a HTTP GET
request with no custom headers and default values for all
FetchOptions attributes. |
java.util.concurrent.Future<HTTPResponse> |
fetchAsync(HTTPRequest request)
Asynchronously execute the specified request and return its response.
|
java.util.concurrent.Future<HTTPResponse> |
fetchAsync(java.net.URL url)
Convenience method for asynchronously retrieving a specific URL
via a HTTP GET request with no custom headers and default values
for all
FetchOptions attributes. |
static final java.lang.String DEFAULT_DEADLINE_PROPERTY
HTTPResponse fetch(java.net.URL url) throws java.io.IOException
FetchOptions
attributes. For more complex requests, use
fetch(HTTPRequest)
.url
- The url to fetch.java.net.MalformedURLException
- If the provided URL is malformed.RequestPayloadTooLargeException
- If the provided payload exceeds the limit.java.io.IOException
- If the remote service could not be contacted or the
URL could not be fetched.java.net.SocketTimeoutException
- If the request takes too long to respond.ResponseTooLargeException
- If the response is too large.javax.net.ssl.SSLHandshakeException
- If the server's SSL
certificate could not be validated and validation was requested.HTTPResponse fetch(HTTPRequest request) throws java.io.IOException
request
- The http request.java.lang.IllegalArgumentException
- If request.getMethod
is not
supported by the URLFetchService
.java.net.MalformedURLException
- If the provided URL is malformed.RequestPayloadTooLargeException
- If the provided payload exceeds the limit.java.io.IOException
- If the remote service could not be contacted or the
URL could not be fetched.java.net.SocketTimeoutException
- If the request takes too long to respond.ResponseTooLargeException
- If response truncation has been disabled
via the FetchOptions
object on request
and the response is
too large. Some responses are too large to even retrieve from the remote
server, and in these cases the exception is thrown even if response
truncation is enabled.javax.net.ssl.SSLHandshakeException
- If the server's SSL
certificate could not be validated and validation was requested.java.util.concurrent.Future<HTTPResponse> fetchAsync(java.net.URL url)
FetchOptions
attributes. For more complex
requests, use fetchAsync(HTTPRequest)
.url
- The url to fetch.fetch(URL)
.java.util.concurrent.Future<HTTPResponse> fetchAsync(HTTPRequest request)
request
- The http request.fetch(HTTPRequest)
.