|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.sponsorpay.sdk.android.publisher.AsyncRequest
public class AsyncRequest
Requests and loads a resource using the HTTP GET method in the background. Will call the
AsyncRequest.AsyncRequestResultListener registered in the constructor in the same thread
which triggered the request / loading process. Uses the Android AsyncTask mechanism.
| Nested Class Summary | |
|---|---|
static interface |
AsyncRequest.AsyncRequestResultListener
|
| Field Summary | |
|---|---|
private static java.lang.String |
ACCEPT_LANGUAGE_HEADER_NAME
Key of the Accept-Language header sent on background requests. |
static java.lang.String |
LOG_TAG
|
private java.lang.String[] |
mCookieStrings
Cookies returned by the server. |
private java.lang.String |
mRequestUrl
URL for the request that will be performed in the background. |
private java.lang.String |
mResponseBody
Server's response body. |
private java.lang.String |
mResponseSignature
Server's response signature, extracted of the "X-Sponsorpay-Response-Signature" header. |
private AsyncRequest.AsyncRequestResultListener |
mResultListener
Registered AsyncRequest.AsyncRequestResultListener to be notified of the request's results when
they become available. |
private int |
mStatusCode
Status code of the server's response. |
private java.lang.Throwable |
mThrownRequestError
Stores an error thrown when launching the request, usually caused by a network connectivity problem. |
static boolean |
shouldLogVerbosely
|
private static java.lang.String |
SIGNATURE_HEADER
Custom SponsorPay HTTP header containing the signature of the response. |
private static java.lang.String |
USER_AGENT_HEADER_NAME
Key of the User-Agent header sent on background requests. |
private static java.lang.String |
USER_AGENT_HEADER_VALUE
Value of the User-Agent header sent on background requests. |
| Constructor Summary | |
|---|---|
AsyncRequest(java.lang.String requestUrl,
AsyncRequest.AsyncRequestResultListener listener)
|
|
| Method Summary | |
|---|---|
boolean |
didRequestThrowError()
Returns the local error thrown when trying to send the request. |
protected java.lang.Void |
doInBackground(java.lang.Void... params)
Performs the request in the background. |
java.lang.String[] |
getCookieStrings()
Gets the cookie strings returned by the server. |
int |
getHttpStatusCode()
Gets the returned HTTP status code. |
java.lang.Throwable |
getRequestThrownError()
Returns the local error thrown when trying to send the request. |
java.lang.String |
getResponseBody()
Gets the response body returned by the server. |
java.lang.String |
getResponseSignature()
|
boolean |
hasCookies()
|
boolean |
hasSucessfulStatusCode()
Returns whether a successful HTTP status code was returned. |
private java.lang.String |
makeAcceptLanguageHeaderValue()
Returns a value for the HTTP Accept-Language header based on the current locale set up for the device. |
protected void |
onPostExecute(java.lang.Void result)
Called in the original thread when a response from the server is available. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static boolean shouldLogVerbosely
public static java.lang.String LOG_TAG
private static java.lang.String USER_AGENT_HEADER_NAME
private static java.lang.String ACCEPT_LANGUAGE_HEADER_NAME
private static java.lang.String USER_AGENT_HEADER_VALUE
private static final java.lang.String SIGNATURE_HEADER
private java.lang.String mRequestUrl
private int mStatusCode
private java.lang.String mResponseBody
private java.lang.String mResponseSignature
private java.lang.String[] mCookieStrings
private AsyncRequest.AsyncRequestResultListener mResultListener
AsyncRequest.AsyncRequestResultListener to be notified of the request's results when
they become available.
private java.lang.Throwable mThrownRequestError
| Constructor Detail |
|---|
public AsyncRequest(java.lang.String requestUrl,
AsyncRequest.AsyncRequestResultListener listener)
requestUrl - URL to send the backgorund request to.listener - AsyncRequest.AsyncRequestResultListener to be notified of the request's results when
they become available.| Method Detail |
|---|
protected java.lang.Void doInBackground(java.lang.Void... params)
AsyncTask when
#execute(Void...) is invoked.
-
private java.lang.String makeAcceptLanguageHeaderValue()
protected void onPostExecute(java.lang.Void result)
result - public java.lang.String[] getCookieStrings()
public boolean hasCookies()
public java.lang.String getResponseBody()
public int getHttpStatusCode()
public java.lang.String getResponseSignature()
public boolean didRequestThrowError()
public java.lang.Throwable getRequestThrownError()
public boolean hasSucessfulStatusCode()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||