Interface URLFetchService
public interface URLFetchService
The
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.
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionfetch
(HTTPRequest request) Execute the specified request and return its response.Convenience method for retrieving a specific URL via a HTTP GET request with no custom headers and default values for allFetchOptions
attributes.fetchAsync
(HTTPRequest request) Asynchronously execute the specified request and return its response.fetchAsync
(URL url) Convenience method for asynchronously retrieving a specific URL via a HTTP GET request with no custom headers and default values for allFetchOptions
attributes.
-
Field Details
-
DEFAULT_DEADLINE_PROPERTY
System property for defining a global default URLFetch deadline.- See Also:
-
DEFAULT_TLS_VALIDATION_PROPERTY
System property to turn on server certificate validation by default. The value of the property should be the string"true"
in order to enable validation.- See Also:
-
-
Method Details
-
fetch
Convenience method for retrieving a specific URL via a HTTP GET request with no custom headers and default values for allFetchOptions
attributes. For more complex requests, usefetch(HTTPRequest)
.- Parameters:
url
- The url to fetch.- Returns:
- The result of the fetch.
- Throws:
MalformedURLException
- If the provided URL is malformed.RequestPayloadTooLargeException
- If the provided payload exceeds the limit.IOException
- If the remote service could not be contacted or the URL could not be fetched.SocketTimeoutException
- If the request takes too long to respond.ResponseTooLargeException
- If the response is too large.SSLHandshakeException
- If the server's SSL certificate could not be validated and validation was requested.
-
fetch
Execute the specified request and return its response.- Parameters:
request
- The http request.- Returns:
- The result of the fetch.
- Throws:
IllegalArgumentException
- Ifrequest.getMethod
is not supported by theURLFetchService
.MalformedURLException
- If the provided URL is malformed.RequestPayloadTooLargeException
- If the provided payload exceeds the limit.IOException
- If the remote service could not be contacted or the URL could not be fetched.SocketTimeoutException
- If the request takes too long to respond.ResponseTooLargeException
- If response truncation has been disabled via theFetchOptions
object onrequest
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.SSLHandshakeException
- If the server's SSL certificate could not be validated and validation was requested.
-
fetchAsync
Convenience method for asynchronously retrieving a specific URL via a HTTP GET request with no custom headers and default values for allFetchOptions
attributes. For more complex requests, usefetchAsync(HTTPRequest)
.- Parameters:
url
- The url to fetch.- Returns:
- A future containing the result of the fetch, or one of
the exceptions documented for
fetch(URL)
.
-
fetchAsync
Asynchronously execute the specified request and return its response.- Parameters:
request
- The http request.- Returns:
- A future containing the result of the fetch, or one of
the exceptions documented for
fetch(HTTPRequest)
.
-