public abstract class**UrlRequest** extends Object  
Controls an HTTP request (GET, PUT, POST etc). Created by[UrlRequest.Builder](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/UrlRequest.Builder.html), which can be obtained 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)). Note: All methods must be called on the[Executor](https://developer.android.com/develop/connectivity/cronet/reference/java/util/concurrent/Executor.html)passed to[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)).  

### Nested Class Summary

|-------|---|---|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| class | [UrlRequest.Builder](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/UrlRequest.Builder.html) || Builder for[UrlRequest](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/UrlRequest.html)s.                                                                                                                                                                                                                                                    |
| class | [UrlRequest.Callback](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/UrlRequest.Callback.html) || Users of Cronet extend this class to receive callbacks indicating the progress of a[UrlRequest](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/UrlRequest.html)being processed.                                                                                                                                                              |
| class | [UrlRequest.Status](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/UrlRequest.Status.html) || Request status values returned by[UrlRequest.getStatus(UrlRequest.StatusListener)](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/UrlRequest.html#getStatus(org.chromium.net.UrlRequest.StatusListener)).                                                                                                                                    |
| class | [UrlRequest.StatusListener](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/UrlRequest.StatusListener.html) || Listener class used with[UrlRequest.getStatus(UrlRequest.StatusListener)](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/UrlRequest.html#getStatus(org.chromium.net.UrlRequest.StatusListener))to receive the status of a[UrlRequest](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/UrlRequest.html). |

### Public Constructor Summary

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

### Public Method Summary

|------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| abstract void    | [cancel](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/UrlRequest.html#cancel())() Cancels the request.                                                                                                                                                                                                                       |
| abstract void    | [followRedirect](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/UrlRequest.html#followRedirect())() Follows a pending redirect.                                                                                                                                                                                                |
| abstract void    | [getStatus](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/UrlRequest.html#getStatus(org.chromium.net.UrlRequest.StatusListener))([UrlRequest.StatusListener](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/UrlRequest.StatusListener.html)listener) Queries the status of the request. |
| abstract boolean | [isDone](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/UrlRequest.html#isDone())() Returns`true`if the request was successfully started and is now finished (completed, canceled, or failed).                                                                                                                                 |
| abstract void    | [read](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/UrlRequest.html#read(java.nio.ByteBuffer))(ByteBuffer buffer) Attempts to read part of the response body into the provided buffer.                                                                                                                                       |
| abstract void    | [start](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/UrlRequest.html#start())() Starts the request, all callbacks go to[UrlRequest.Callback](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/UrlRequest.Callback.html).                                                                 |

### 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()                    |

## Public Constructors

#### public**UrlRequest**()

<br />

## Public Methods

#### public abstract void**cancel**()

Cancels the request. Can be called at any time.[onCanceled()](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/UrlRequest.Callback.html#onCanceled(org.chromium.net.UrlRequest,%20org.chromium.net.UrlResponseInfo))will be invoked when cancellation is complete and no further callback methods will be invoked. If the request has completed or has not started, calling`cancel()`has no effect and`onCanceled()`will not be invoked. If the[Executor](https://developer.android.com/develop/connectivity/cronet/reference/java/util/concurrent/Executor.html)passed in during`UrlRequest`construction runs tasks on a single thread, and`cancel()`is called on that thread, no callback methods (besides`onCanceled()`) will be invoked after`cancel()`is called. Otherwise, at most one callback method may be invoked after`cancel()`has completed.  

#### public abstract void**followRedirect**()

Follows a pending redirect. Must only be called at most once for each invocation of[onRedirectReceived()](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/UrlRequest.Callback.html#onRedirectReceived(org.chromium.net.UrlRequest,%20org.chromium.net.UrlResponseInfo,%20java.lang.String)).  

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

Queries the status of the request.  

##### Parameters

| listener | a[UrlRequest.StatusListener](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/UrlRequest.StatusListener.html)that will be invoked with the request's current status.`listener`will be invoked back on the[Executor](https://developer.android.com/develop/connectivity/cronet/reference/java/util/concurrent/Executor.html)passed in when the request was created. |
|----------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|

#### public abstract boolean**isDone**()

Returns`true`if the request was successfully started and is now finished (completed, canceled, or failed).  

##### Returns

- `true`if the request was successfully started and is now finished (completed, canceled, or failed).  

#### public abstract void**read**(ByteBuffer buffer)

Attempts to read part of the response body into the provided buffer. Must only be called at most once in response to each invocation of the[onResponseStarted()](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/UrlRequest.Callback.html#onResponseStarted(org.chromium.net.UrlRequest,%20org.chromium.net.UrlResponseInfo))and[onReadCompleted()](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/UrlRequest.Callback.html#onReadCompleted(org.chromium.net.UrlRequest,%20org.chromium.net.UrlResponseInfo,%20java.nio.ByteBuffer))methods of the[UrlRequest.Callback](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/UrlRequest.Callback.html). Each call will result in an asynchronous call to either the[Callback's](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/UrlRequest.Callback.html)[onReadCompleted()](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/UrlRequest.Callback.html#onReadCompleted(org.chromium.net.UrlRequest,%20org.chromium.net.UrlResponseInfo,%20java.nio.ByteBuffer))method if data is read, its[onSucceeded()](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/UrlRequest.Callback.html#onSucceeded(org.chromium.net.UrlRequest,%20org.chromium.net.UrlResponseInfo))method if there's no more data to read, or its[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))method if there's an error.  

##### Parameters

| buffer | [ByteBuffer](https://developer.android.com/develop/connectivity/cronet/reference/java/nio/ByteBuffer.html)to write response body to. Must be a direct ByteBuffer. The embedder must not read or modify buffer's position, limit, or data between its position and limit until the request calls back into the[UrlRequest.Callback](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/UrlRequest.Callback.html). |
|--------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|

#### public abstract void**start**()

Starts the request, all callbacks go to[UrlRequest.Callback](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/UrlRequest.Callback.html). May only be called once. May not be called if[cancel()](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/UrlRequest.html#cancel())has been called.