Interface URLFetchService (2.0.0)

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.

Static Fields

DEFAULT_DEADLINE_PROPERTY

public static final String DEFAULT_DEADLINE_PROPERTY

System property for defining a global default URLFetch deadline.

Field Value
TypeDescription
String

DEFAULT_TLS_VALIDATION_PROPERTY

public static final String 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.

Field Value
TypeDescription
String

Methods

fetch(HTTPRequest request)

public abstract HTTPResponse fetch(HTTPRequest request)

Execute the specified request and return its response.

Parameter
NameDescription
requestHTTPRequest

The http request.

Returns
TypeDescription
HTTPResponse

The result of the fetch.

Exceptions
TypeDescription
IOException

If request.getMethod is not supported by the URLFetchService.

fetch(URL url)

public abstract HTTPResponse fetch(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. For more complex requests, use #fetch(HTTPRequest).

Parameter
NameDescription
urlURL

The url to fetch.

Returns
TypeDescription
HTTPResponse

The result of the fetch.

Exceptions
TypeDescription
IOException

If the provided URL is malformed.

fetchAsync(HTTPRequest request)

public abstract Future<HTTPResponse> fetchAsync(HTTPRequest request)

Asynchronously execute the specified request and return its response.

Parameter
NameDescription
requestHTTPRequest

The http request.

Returns
TypeDescription
Future<HTTPResponse>

A future containing the result of the fetch, or one of the exceptions documented for #fetch(HTTPRequest).

fetchAsync(URL url)

public abstract Future<HTTPResponse> fetchAsync(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. For more complex requests, use #fetchAsync(HTTPRequest).

Parameter
NameDescription
urlURL

The url to fetch.

Returns
TypeDescription
Future<HTTPResponse>

A future containing the result of the fetch, or one of the exceptions documented for #fetch(URL).