public static abstract class**UrlRequest.Builder** extends Object  
Builder for[UrlRequest](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/UrlRequest.html)s. Allows configuring requests before constructing them with[build()](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/UrlRequest.Builder.html#build()). The builder can be created by calling[CronetEngine.newUrlRequestBuilder(String, UrlRequest.Callback, Executor)](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/CronetEngine.html#newUrlRequestBuilder(java.lang.String,%20org.chromium.net.UrlRequest.Callback,%20java.util.concurrent.Executor)).  

### Constant Summary

|-----|-------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------|
| int | [REQUEST_PRIORITY_HIGHEST](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/UrlRequest.Builder.html#REQUEST_PRIORITY_HIGHEST) | Highest request priority.  |
| int | [REQUEST_PRIORITY_IDLE](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/UrlRequest.Builder.html#REQUEST_PRIORITY_IDLE)       | Lowest request priority.   |
| int | [REQUEST_PRIORITY_LOW](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/UrlRequest.Builder.html#REQUEST_PRIORITY_LOW)         | Low request priority.      |
| int | [REQUEST_PRIORITY_LOWEST](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/UrlRequest.Builder.html#REQUEST_PRIORITY_LOWEST)   | Very low request priority. |
| int | [REQUEST_PRIORITY_MEDIUM](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/UrlRequest.Builder.html#REQUEST_PRIORITY_MEDIUM)   | Medium request priority.   |

### Public Constructor Summary

|---|-------------------------------------------------------------------------------------------------------------------------------------|
|   | [Builder](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/UrlRequest.Builder.html#Builder())() |

### Public Method Summary

|--------------------------------------------------------------------------------------------------------------------------------------------| |
| abstract[UrlRequest.Builder](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/UrlRequest.Builder.html) | [addHeader](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/UrlRequest.Builder.html#addHeader(java.lang.String,%20java.lang.String))(String header, String value) Adds a request header.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| [UrlRequest.Builder](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/UrlRequest.Builder.html)         | [addRequestAnnotation](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/UrlRequest.Builder.html#addRequestAnnotation(java.lang.Object))(Object annotation) Associates the annotation object with this request.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| abstract[UrlRequest.Builder](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/UrlRequest.Builder.html) | [allowDirectExecutor](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/UrlRequest.Builder.html#allowDirectExecutor())() Marks that the executors this request will use to notify callbacks (for`UploadDataProvider`s and`UrlRequest.Callback`s) is intentionally performing inline execution, like Guava's directExecutor or[ThreadPoolExecutor.CallerRunsPolicy](https://developer.android.com/develop/connectivity/cronet/reference/java/util/concurrent/ThreadPoolExecutor.CallerRunsPolicy.html).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| abstract[UrlRequest](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/UrlRequest.html)                 | [build](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/UrlRequest.Builder.html#build())() Creates a[UrlRequest](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/UrlRequest.html)using configuration within this[UrlRequest.Builder](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/UrlRequest.Builder.html).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| abstract[UrlRequest.Builder](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/UrlRequest.Builder.html) | [disableCache](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/UrlRequest.Builder.html#disableCache())() Disables cache for the request.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| abstract[UrlRequest.Builder](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/UrlRequest.Builder.html) | [setHttpMethod](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/UrlRequest.Builder.html#setHttpMethod(java.lang.String))(String method) Sets the HTTP method verb to use for this request.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| abstract[UrlRequest.Builder](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/UrlRequest.Builder.html) | [setPriority](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/UrlRequest.Builder.html#setPriority(int))(int priority) Sets priority of the request which should be one of the[REQUEST_PRIORITY_*](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/UrlRequest.Builder.html#REQUEST_PRIORITY_IDLE)values.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| [UrlRequest.Builder](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/UrlRequest.Builder.html)         | [setRequestFinishedListener](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/UrlRequest.Builder.html#setRequestFinishedListener(org.chromium.net.RequestFinishedInfo.Listener))([RequestFinishedInfo.Listener](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/RequestFinishedInfo.Listener.html)listener) Sets a listener that gets invoked after[onCanceled()](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/UrlRequest.Callback.html#onCanceled(org.chromium.net.UrlRequest,%20org.chromium.net.UrlResponseInfo)),[onFailed()](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/UrlRequest.Callback.html#onFailed(org.chromium.net.UrlRequest,%20org.chromium.net.UrlResponseInfo,%20org.chromium.net.CronetException))or[onSucceeded()](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/UrlRequest.Callback.html#onSucceeded(org.chromium.net.UrlRequest,%20org.chromium.net.UrlResponseInfo))return. |
| [UrlRequest.Builder](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/UrlRequest.Builder.html)         | [setTrafficStatsTag](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/UrlRequest.Builder.html#setTrafficStatsTag(int))(int tag) Sets[TrafficStats](https://developer.android.com/develop/connectivity/cronet/reference/android/net/TrafficStats.html)tag to use when accounting socket traffic caused by this request.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| [UrlRequest.Builder](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/UrlRequest.Builder.html)         | [setTrafficStatsUid](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/UrlRequest.Builder.html#setTrafficStatsUid(int))(int uid) Sets specific UID to use when accounting socket traffic caused by this request.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| abstract[UrlRequest.Builder](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/UrlRequest.Builder.html) | [setUploadDataProvider](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/UrlRequest.Builder.html#setUploadDataProvider(org.chromium.net.UploadDataProvider,%20java.util.concurrent.Executor))([UploadDataProvider](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/UploadDataProvider.html)uploadDataProvider, Executor executor) Sets upload data provider.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |

### Inherited Method Summary

From class java.lang.Object  

|------------------|---------------------------|
| Object           | clone()                   |
| boolean          | equals(Object arg0)       |
| void             | finalize()                |
| final Class\<?\> | getClass()                |
| int              | hashCode()                |
| final void       | notify()                  |
| final void       | notifyAll()               |
| String           | toString()                |
| final void       | wait(long arg0, int arg1) |
| final void       | wait(long arg0)           |
| final void       | wait()                    |

## Constants

#### public static final int**REQUEST_PRIORITY_HIGHEST**

Highest request priority. Passed to[setPriority(int)](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/UrlRequest.Builder.html#setPriority(int)).  
Constant Value:4  

#### public static final int**REQUEST_PRIORITY_IDLE**

Lowest request priority. Passed to[setPriority(int)](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/UrlRequest.Builder.html#setPriority(int)).  
Constant Value:0  

#### public static final int**REQUEST_PRIORITY_LOW**

Low request priority. Passed to[setPriority(int)](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/UrlRequest.Builder.html#setPriority(int)).  
Constant Value:2  

#### public static final int**REQUEST_PRIORITY_LOWEST**

Very low request priority. Passed to[setPriority(int)](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/UrlRequest.Builder.html#setPriority(int)).  
Constant Value:1  

#### public static final int**REQUEST_PRIORITY_MEDIUM**

Medium request priority. Passed to[setPriority(int)](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/UrlRequest.Builder.html#setPriority(int)). This is the default priority given to the request.  
Constant Value:3

## Public Constructors

#### public**Builder**()

<br />

## Public Methods

#### public abstract[UrlRequest.Builder](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/UrlRequest.Builder.html)**addHeader**(String header, String value)

Adds a request header.  

##### Parameters

| header | header name.  |
| value  | header value. |
|--------|---------------|

##### Returns

- the builder to facilitate chaining.  

#### public[UrlRequest.Builder](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/UrlRequest.Builder.html)**addRequestAnnotation**(Object annotation)

Associates the annotation object with this request. May add more than one. Passed through to a[RequestFinishedInfo.Listener](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/RequestFinishedInfo.Listener.html), see[RequestFinishedInfo.getAnnotations()](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/RequestFinishedInfo.html#getAnnotations()).  

##### Parameters

| annotation | an object to pass on to the[RequestFinishedInfo.Listener](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/RequestFinishedInfo.Listener.html)with a[RequestFinishedInfo](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/RequestFinishedInfo.html). |
|------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|

##### Returns

- the builder to facilitate chaining.  

#### public abstract[UrlRequest.Builder](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/UrlRequest.Builder.html)**allowDirectExecutor**()

Marks that the executors this request will use to notify callbacks (for`UploadDataProvider`s and`UrlRequest.Callback`s) is intentionally performing inline execution, like Guava's directExecutor or[ThreadPoolExecutor.CallerRunsPolicy](https://developer.android.com/develop/connectivity/cronet/reference/java/util/concurrent/ThreadPoolExecutor.CallerRunsPolicy.html).

**Warning:**This option makes it easy to accidentally block the network thread. It should not be used if your callbacks perform disk I/O, acquire locks, or call into other code you don't carefully control and audit.  

#### public abstract[UrlRequest](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/UrlRequest.html)**build**()

Creates a[UrlRequest](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/UrlRequest.html)using configuration within this[UrlRequest.Builder](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/UrlRequest.Builder.html). The returned`UrlRequest`can then be started by calling[UrlRequest.start()](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/UrlRequest.html#start()).  

##### Returns

- constructed[UrlRequest](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/UrlRequest.html)using configuration within this[UrlRequest.Builder](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/UrlRequest.Builder.html).  

#### public abstract[UrlRequest.Builder](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/UrlRequest.Builder.html)**disableCache**()

Disables cache for the request. If context is not set up to use cache, this call has no effect.  

##### Returns

- the builder to facilitate chaining.  

#### public abstract[UrlRequest.Builder](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/UrlRequest.Builder.html)**setHttpMethod**(String method)

Sets the HTTP method verb to use for this request.

The default when this method is not called is "GET" if the request has no body or "POST" if it does.  

##### Parameters

| method | "GET", "HEAD", "DELETE", "POST" or "PUT". |
|--------|-------------------------------------------|

##### Returns

- the builder to facilitate chaining.  

#### public abstract[UrlRequest.Builder](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/UrlRequest.Builder.html)**setPriority**(int priority)

Sets priority of the request which should be one of the[REQUEST_PRIORITY_*](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/UrlRequest.Builder.html#REQUEST_PRIORITY_IDLE)values. The request is given[REQUEST_PRIORITY_MEDIUM](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/UrlRequest.Builder.html#REQUEST_PRIORITY_MEDIUM)priority if this method is not called.  

##### Parameters

| priority | priority of the request which should be one of the[REQUEST_PRIORITY_*](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/UrlRequest.Builder.html#REQUEST_PRIORITY_IDLE)values. |
|----------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|

##### Returns

- the builder to facilitate chaining.  

#### public[UrlRequest.Builder](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/UrlRequest.Builder.html)**setRequestFinishedListener**([RequestFinishedInfo.Listener](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/RequestFinishedInfo.Listener.html)listener)

Sets a listener that gets invoked after[onCanceled()](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/UrlRequest.Callback.html#onCanceled(org.chromium.net.UrlRequest,%20org.chromium.net.UrlResponseInfo)),[onFailed()](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/UrlRequest.Callback.html#onFailed(org.chromium.net.UrlRequest,%20org.chromium.net.UrlResponseInfo,%20org.chromium.net.CronetException))or[onSucceeded()](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/UrlRequest.Callback.html#onSucceeded(org.chromium.net.UrlRequest,%20org.chromium.net.UrlResponseInfo))return.

The listener is invoked with the request finished info on an[Executor](https://developer.android.com/develop/connectivity/cronet/reference/java/util/concurrent/Executor.html)provided by[getExecutor()](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/RequestFinishedInfo.Listener.html#getExecutor()).  

##### Parameters

| listener | the listener for finished requests. |
|----------|-------------------------------------|

##### Returns

- the builder to facilitate chaining.  

#### public[UrlRequest.Builder](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/UrlRequest.Builder.html)**setTrafficStatsTag**(int tag)

Sets[TrafficStats](https://developer.android.com/develop/connectivity/cronet/reference/android/net/TrafficStats.html)tag to use when accounting socket traffic caused by this request. See[TrafficStats](https://developer.android.com/develop/connectivity/cronet/reference/android/net/TrafficStats.html)for more information. If no tag is set (e.g. this method isn't called), then Android accounts for the socket traffic caused by this request as if the tag value were set to 0.

**NOTE:**Setting a tag disallows sharing of sockets with requests with other tags, which may adversely effect performance by prohibiting connection sharing. In other words use of multiplexed sockets (e.g. HTTP/2 and QUIC) will only be allowed if all requests have the same socket tag.  

##### Parameters

| tag | the tag value used to when accounting for socket traffic caused by this request. Tags between 0xFFFFFF00 and 0xFFFFFFFF are reserved and used internally by system services like[DownloadManager](https://developer.android.com/develop/connectivity/cronet/reference/android/app/DownloadManager.html)when performing traffic on behalf of an application. |
|-----|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|

##### Returns

- the builder to facilitate chaining.  

#### public[UrlRequest.Builder](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/UrlRequest.Builder.html)**setTrafficStatsUid**(int uid)

Sets specific UID to use when accounting socket traffic caused by this request. See[TrafficStats](https://developer.android.com/develop/connectivity/cronet/reference/android/net/TrafficStats.html)for more information. Designed for use when performing an operation on behalf of another application. Caller must hold`MODIFY_NETWORK_ACCOUNTING`permission. By default traffic is attributed to UID of caller.

**NOTE:**Setting a UID disallows sharing of sockets with requests with other UIDs, which may adversely effect performance by prohibiting connection sharing. In other words use of multiplexed sockets (e.g. HTTP/2 and QUIC) will only be allowed if all requests have the same UID set.  

##### Parameters

| uid | the UID to attribute socket traffic caused by this request. |
|-----|-------------------------------------------------------------|

##### Returns

- the builder to facilitate chaining.  

#### public abstract[UrlRequest.Builder](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/UrlRequest.Builder.html)**setUploadDataProvider**([UploadDataProvider](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/UploadDataProvider.html)uploadDataProvider, Executor executor)

Sets upload data provider. Switches method to "POST" if not explicitly set. Starting the request will throw an exception if a Content-Type header is not set.  

##### Parameters

| uploadDataProvider |                                              responsible for providing the upload data.                                               |
|      executor      | All`uploadDataProvider`methods will be invoked using this`Executor`. May optionally be the same`Executor`the request itself is using. |
|--------------------|---------------------------------------------------------------------------------------------------------------------------------------|

##### Returns

- the builder to facilitate chaining.