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
Type Description
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
Type Description
String

Methods

fetch(HTTPRequest request)

public abstract HTTPResponse fetch(HTTPRequest request)

Execute the specified request and return its response.

Parameter
Name Description
request HTTPRequest

The http request.

Returns
Type Description
HTTPResponse

The result of the fetch.

Exceptions
Type Description
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
Name Description
url URL

The url to fetch.

Returns
Type Description
HTTPResponse

The result of the fetch.

Exceptions
Type Description
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
Name Description
request HTTPRequest

The http request.

Returns
Type Description
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
Name Description
url URL

The url to fetch.

Returns
Type Description
Future<HTTPResponse>

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