T - JSON type of response expectedpublic abstract class JsonRequest<T> extends Request<T>
Request.Method, Request.Priority| Modifier and Type | Field and Description |
|---|---|
protected static String |
PROTOCOL_CHARSET
Default charset for JSON request.
|
| Constructor and Description |
|---|
JsonRequest(int method,
String url,
String requestBody,
Response.Listener<T> listener,
Response.ErrorListener errorListener) |
JsonRequest(String url,
String requestBody,
Response.Listener<T> listener,
Response.ErrorListener errorListener)
Deprecated.
Use
#JsonRequest(int, String, String, Listener, ErrorListener). |
| Modifier and Type | Method and Description |
|---|---|
protected void |
deliverResponse(T response)
Subclasses must implement this to perform delivery of the parsed
response to their listeners.
|
byte[] |
getBody()
Returns the raw POST or PUT body to be sent.
|
String |
getBodyContentType()
Returns the content type of the POST or PUT body.
|
byte[] |
getPostBody()
Deprecated.
Use
getBody(). |
String |
getPostBodyContentType()
Deprecated.
Use
getBodyContentType(). |
protected abstract Response<T> |
parseNetworkResponse(NetworkResponse response)
Subclasses must implement this to parse the raw network response
and return an appropriate response type.
|
addMarker, cancel, compareTo, deliverError, getCacheEntry, getCacheKey, getErrorListener, getHeaders, getMethod, getParams, getParamsEncoding, getPostParams, getPostParamsEncoding, getPriority, getRetryPolicy, getSequence, getTag, getTimeoutMs, getTrafficStatsTag, getUrl, hasHadResponseDelivered, isCanceled, markDelivered, parseNetworkError, setCacheEntry, setRequestQueue, setRetryPolicy, setSequence, setShouldCache, setTag, shouldCache, toStringprotected static final String PROTOCOL_CHARSET
public JsonRequest(String url, String requestBody, Response.Listener<T> listener, Response.ErrorListener errorListener)
#JsonRequest(int, String, String, Listener, ErrorListener).getPostBody()
or Request.getPostParams() is overridden (which defaults to POST).public JsonRequest(int method,
String url,
String requestBody,
Response.Listener<T> listener,
Response.ErrorListener errorListener)
protected void deliverResponse(T response)
RequestdeliverResponse in class Request<T>response - The parsed response returned by
Request.parseNetworkResponse(NetworkResponse)protected abstract Response<T> parseNetworkResponse(NetworkResponse response)
RequestparseNetworkResponse in class Request<T>response - Response from the networkpublic String getPostBodyContentType()
getBodyContentType().getPostBodyContentType in class Request<T>public byte[] getPostBody()
getBody().RequestgetPostBody in class Request<T>public String getBodyContentType()
RequestgetBodyContentType in class Request<T>public byte[] getBody()
RequestBy default, the body consists of the request parameters in
application/x-www-form-urlencoded format. When overriding this method, consider overriding
Request.getBodyContentType() as well to match the new body format.
Copyright © 2015. All rights reserved.