java.lang.Object | |
↳ | com.android.volley.Request<T> |
Known Direct Subclasses |
Known Indirect Subclasses |
Base class for all network requests.
Nested Classes | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
interface | Request.Method | Supported request methods. | |||||||||
enum | Request.Priority | Priority values. |
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Request(String url, Response.ErrorListener listener)
This constructor is deprecated.
Use
Request(int, String, com.android.volley.Response.ErrorListener) .
| |||||||||||
Request(int method, String url, Response.ErrorListener listener)
Creates a new request with the given method (one of the values from
Request.Method ),
URL, and error listener. |
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
void |
addMarker(String tag)
Adds an event to this request's event log; for debugging.
| ||||||||||
void |
cancel()
Mark this request as canceled.
| ||||||||||
int |
compareTo(Request<T> other)
Our comparator sorts from high to low priority, and secondarily by
sequence number to provide FIFO ordering.
| ||||||||||
void |
deliverError(VolleyError error)
Delivers error message to the ErrorListener that the Request was
initialized with.
| ||||||||||
byte[] |
getBody()
Returns the raw POST or PUT body to be sent.
| ||||||||||
String |
getBodyContentType()
Returns the content type of the POST or PUT body.
| ||||||||||
Cache.Entry |
getCacheEntry()
Returns the annotated cache entry, or null if there isn't one.
| ||||||||||
String |
getCacheKey()
Returns the cache key for this request.
| ||||||||||
Response.ErrorListener | getErrorListener() | ||||||||||
Map<String, String> |
getHeaders()
Returns a list of extra HTTP headers to go along with this request.
| ||||||||||
int |
getMethod()
Return the method for this request.
| ||||||||||
byte[] |
getPostBody()
This method is deprecated.
Use
getBody() instead.
| ||||||||||
String |
getPostBodyContentType()
This method is deprecated.
Use
getBodyContentType() instead.
| ||||||||||
Request.Priority |
getPriority()
Returns the
Request.Priority of this request; NORMAL by default. | ||||||||||
RetryPolicy |
getRetryPolicy()
Returns the retry policy that should be used for this request.
| ||||||||||
final int |
getSequence()
Returns the sequence number of this request.
| ||||||||||
Object |
getTag()
Returns this request's tag.
| ||||||||||
final int |
getTimeoutMs()
Returns the socket timeout in milliseconds per retry attempt.
| ||||||||||
int | getTrafficStatsTag() | ||||||||||
String |
getUrl()
Returns the URL of this request.
| ||||||||||
boolean |
hasHadResponseDelivered()
Returns true if this request has had a response delivered for it.
| ||||||||||
boolean |
isCanceled()
Returns true if this request has been canceled.
| ||||||||||
void |
markDelivered()
Mark this request as having a response delivered on it.
| ||||||||||
Request<?> |
setCacheEntry(Cache.Entry entry)
Annotates this request with an entry retrieved for it from cache.
| ||||||||||
Request<?> |
setRequestQueue(RequestQueue requestQueue)
Associates this request with the given queue.
| ||||||||||
Request<?> |
setRetryPolicy(RetryPolicy retryPolicy)
Sets the retry policy for this request.
| ||||||||||
final Request<?> |
setSequence(int sequence)
Sets the sequence number of this request.
| ||||||||||
final Request<?> |
setShouldCache(boolean shouldCache)
Set whether or not responses to this request should be cached.
| ||||||||||
Request<?> |
setTag(Object tag)
Set a tag on this request.
| ||||||||||
final boolean |
shouldCache()
Returns true if responses to this request should be cached.
| ||||||||||
String | toString() |
Protected Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
abstract void |
deliverResponse(T response)
Subclasses must implement this to perform delivery of the parsed
response to their listeners.
| ||||||||||
Map<String, String> |
getParams()
Returns a Map of parameters to be used for a POST or PUT request.
| ||||||||||
String |
getParamsEncoding()
Returns which encoding should be used when converting POST or PUT parameters returned by
getParams() into a raw POST or PUT body. | ||||||||||
Map<String, String> |
getPostParams()
This method is deprecated.
Use
getParams() instead.
| ||||||||||
String |
getPostParamsEncoding()
This method is deprecated.
Use
getParamsEncoding() instead.
| ||||||||||
VolleyError |
parseNetworkError(VolleyError volleyError)
Subclasses can override this method to parse 'networkError' and return a more specific error.
| ||||||||||
abstract Response<T> |
parseNetworkResponse(NetworkResponse response)
Subclasses must implement this to parse the raw network response
and return an appropriate response type.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
| |||||||||||
From interface
java.lang.Comparable
|
This constructor is deprecated.
Use Request(int, String, com.android.volley.Response.ErrorListener)
.
Creates a new request with the given URL and error listener. Note that the normal response listener is not provided here as delivery of responses is provided by subclasses, who have a better idea of how to deliver an already-parsed response.
Creates a new request with the given method (one of the values from Request.Method
),
URL, and error listener. Note that the normal response listener is not provided here as
delivery of responses is provided by subclasses, who have a better idea of how to deliver
an already-parsed response.
Adds an event to this request's event log; for debugging.
Mark this request as canceled. No callback will be delivered.
Our comparator sorts from high to low priority, and secondarily by sequence number to provide FIFO ordering.
Delivers error message to the ErrorListener that the Request was initialized with.
error | Error details |
---|
Returns the raw POST or PUT body to be sent.
By default, the body consists of the request parameters in
application/x-www-form-urlencoded format. When overriding this method, consider overriding
getBodyContentType()
as well to match the new body format.
AuthFailureError | in the event of auth failure |
---|
Returns the content type of the POST or PUT body.
Returns the cache key for this request. By default, this is the URL.
Returns a list of extra HTTP headers to go along with this request. Can
throw AuthFailureError
as authentication may be required to
provide these values.
AuthFailureError | In the event of auth failure |
---|
Return the method for this request. Can be one of the values in Request.Method
.
This method is deprecated.
Use getBody()
instead.
Returns the raw POST body to be sent.
AuthFailureError | In the event of auth failure |
---|
Returns the Request.Priority
of this request; NORMAL
by default.
Returns the sequence number of this request.
Returns the socket timeout in milliseconds per retry attempt. (This value can be changed
per retry attempt if a backoff is specified via backoffTimeout()). If there are no retry
attempts remaining, this will cause delivery of a TimeoutError
error.
Returns the URL of this request.
Returns true if this request has had a response delivered for it.
Returns true if this request has been canceled.
Mark this request as having a response delivered on it. This can be used later in the request's lifetime for suppressing identical responses.
Annotates this request with an entry retrieved for it from cache. Used for cache coherency support.
Associates this request with the given queue. The request queue will be notified when this request has finished.
Sets the retry policy for this request.
Sets the sequence number of this request. Used by RequestQueue
.
Set whether or not responses to this request should be cached.
Set a tag on this request. Can be used to cancel all requests with this
tag by cancelAll(Object)
.
Returns true if responses to this request should be cached.
Subclasses must implement this to perform delivery of the parsed response to their listeners. The given response is guaranteed to be non-null; responses that fail to parse are not delivered.
response | The parsed response returned by
parseNetworkResponse(NetworkResponse)
|
---|
Returns a Map of parameters to be used for a POST or PUT request. Can throw
AuthFailureError
as authentication may be required to provide these values.
Note that you can directly override getBody()
for custom data.
AuthFailureError | in the event of auth failure |
---|
Returns which encoding should be used when converting POST or PUT parameters returned by
getParams()
into a raw POST or PUT body.
This controls both encodings:
This method is deprecated.
Use getParams()
instead.
Returns a Map of POST parameters to be used for this request, or null if
a simple GET should be used. Can throw AuthFailureError
as
authentication may be required to provide these values.
Note that only one of getPostParams() and getPostBody() can return a non-null value.
AuthFailureError | In the event of auth failure |
---|
This method is deprecated.
Use getParamsEncoding()
instead.
Returns which encoding should be used when converting POST parameters returned by
getPostParams()
into a raw POST body.
This controls both encodings:
Subclasses can override this method to parse 'networkError' and return a more specific error.
The default implementation just returns the passed 'networkError'.
volleyError | the error retrieved from the network |
---|
Subclasses must implement this to parse the raw network response and return an appropriate response type. This method will be called from a worker thread. The response will not be delivered if you return null.
response | Response from the network |
---|