@Immutable @LevelUpApi(contract=PUBLIC) public abstract class AbstractRequest extends Object implements Parcelable
| Modifier and Type | Class and Description |
|---|---|
static class |
AbstractRequest.BadRequestException
Exception that is thrown if a request is invalid at the time it it sent.
|
Parcelable.ClassLoaderCreator<T>, Parcelable.Creator<T>CONTENTS_FILE_DESCRIPTOR, PARCELABLE_WRITE_RETURN_VALUE| Constructor and Description |
|---|
AbstractRequest(HttpMethod method,
String url,
Map<String,String> requestHeaders,
Map<String,String> queryParams)
Create a new
AbstractRequest. |
AbstractRequest(HttpMethod method,
Uri url,
Map<String,String> requestHeaders)
Create a new
AbstractRequest from an absolute URL. |
AbstractRequest(Parcel in)
Constructor for parceling.
|
| Modifier and Type | Method and Description |
|---|---|
int |
describeContents() |
boolean |
equals(Object obj) |
abstract int |
getBodyLength(Context context) |
HttpMethod |
getMethod() |
Map<String,String> |
getQueryParams(Context context) |
Map<String,String> |
getRequestHeaders(Context context) |
URL |
getUrl(Context context) |
String |
getUrlString(Context context) |
int |
hashCode() |
String |
toString() |
abstract void |
writeBodyToStream(Context context,
OutputStream stream)
Subclasses must implement this write the POST body (if it has one) to the
OutputStream passed. |
void |
writeToParcel(Parcel dest,
int flags) |
public AbstractRequest(HttpMethod method, String url, Map<String,String> requestHeaders, Map<String,String> queryParams)
AbstractRequest.
Note that there are some representation invariants for the AbstractRequest object.
For example, a HttpMethod.GET cannot contain a body.
method - the HttpMethod of the request type.url - the URL to request (and to append query string parameters to).requestHeaders - the headers to add to the request. This cannot contain null keys or
null values.queryParams - the query string parameters. This cannot contain null keys or null values.public AbstractRequest(HttpMethod method, Uri url, Map<String,String> requestHeaders) throws IllegalArgumentException
AbstractRequest from an absolute URL.method - the HttpMethod of the request type.url - The URL to request. This can include query parameters.requestHeaders - the headers to add to the request. This cannot contain null keys or
null values.IllegalArgumentException - if the URI passed in isn't an absolute URL.public AbstractRequest(Parcel in)
in - the parcel to read frompublic Map<String,String> getRequestHeaders(Context context)
context - the context to use to get context dependent headers.Collections.unmodifiableMap(Map).public Map<String,String> getQueryParams(Context context)
context - the context to use to get context dependent parameters.Collections.unmodifiableMap(Map).public String getUrlString(Context context) throws AbstractRequest.BadRequestException
context - Application context.AbstractRequest.BadRequestException - if the request is invalid.public final URL getUrl(Context context) throws AbstractRequest.BadRequestException
context - the context to use to get context dependent parametersURL to request, including query string parameters.AbstractRequest.BadRequestException - if the request is invalid.public final HttpMethod getMethod()
HttpMethod for the requestpublic abstract void writeBodyToStream(Context context, OutputStream stream) throws IOException
OutputStream passed.context - the Application context.stream - the OutputStream to write the POST body to.IOException - if writing to the OutputStream failspublic abstract int getBodyLength(Context context)
context - the Application context.public int describeContents()
describeContents in interface Parcelablepublic void writeToParcel(Parcel dest, int flags)
writeToParcel in interface Parcelable