# Interface URLFetchService (5.0.3)

    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** |
| `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` |   |

### 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** |
| `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` |   |

## Methods

### fetch(HTTPRequest request)

    public abstract HTTPResponse fetch(HTTPRequest request)

Execute the specified request and return its response.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/appengine/docs/standard/java-gen2/reference/services/bundled/latest/com.google.appengine.api.urlfetch.HTTPRequest` The http request. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/appengine/docs/standard/java-gen2/reference/services/bundled/latest/com.google.appengine.api.urlfetch.HTTPResponse` | The result of the fetch. |

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/io/IOException.html` | 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](https://docs.cloud.google.com/appengine/docs/standard/java-gen2/reference/services/bundled/latest/com.google.appengine.api.urlfetch.FetchOptions) attributes. For more complex requests, use
[#fetch(HTTPRequest)](https://docs.cloud.google.com/appengine/docs/standard/java-gen2/reference/services/bundled/latest/com.google.appengine.api.urlfetch.URLFetchService#com_google_appengine_api_urlfetch_URLFetchService_fetch_com_google_appengine_api_urlfetch_HTTPRequest_).

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `url` | `https://docs.oracle.com/javase/8/docs/api/java/net/URL.html` The url to fetch. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/appengine/docs/standard/java-gen2/reference/services/bundled/latest/com.google.appengine.api.urlfetch.HTTPResponse` | The result of the fetch. |

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/io/IOException.html` | 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` | `https://docs.cloud.google.com/appengine/docs/standard/java-gen2/reference/services/bundled/latest/com.google.appengine.api.urlfetch.HTTPRequest` The http request. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/Future.html<https://docs.cloud.google.com/appengine/docs/standard/java-gen2/reference/services/bundled/latest/com.google.appengine.api.urlfetch.HTTPResponse>` | A future containing the result of the fetch, or one of the exceptions documented for [#fetch(HTTPRequest)](https://docs.cloud.google.com/appengine/docs/standard/java-gen2/reference/services/bundled/latest/com.google.appengine.api.urlfetch.URLFetchService#com_google_appengine_api_urlfetch_URLFetchService_fetch_com_google_appengine_api_urlfetch_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](https://docs.cloud.google.com/appengine/docs/standard/java-gen2/reference/services/bundled/latest/com.google.appengine.api.urlfetch.FetchOptions) attributes. For more complex
requests, use [#fetchAsync(HTTPRequest)](https://docs.cloud.google.com/appengine/docs/standard/java-gen2/reference/services/bundled/latest/com.google.appengine.api.urlfetch.URLFetchService#com_google_appengine_api_urlfetch_URLFetchService_fetchAsync_com_google_appengine_api_urlfetch_HTTPRequest_).

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `url` | `https://docs.oracle.com/javase/8/docs/api/java/net/URL.html` The url to fetch. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/Future.html<https://docs.cloud.google.com/appengine/docs/standard/java-gen2/reference/services/bundled/latest/com.google.appengine.api.urlfetch.HTTPResponse>` | A future containing the result of the fetch, or one of the exceptions documented for [#fetch(URL)](https://docs.cloud.google.com/appengine/docs/standard/java-gen2/reference/services/bundled/latest/com.google.appengine.api.urlfetch.URLFetchService#com_google_appengine_api_urlfetch_URLFetchService_fetch_java_net_URL_). |