public class AsyncHttpClient
extends java.lang.Object
RequestParams
instance, and responses can be handled by passing an anonymously overridden ResponseHandlerInterface
instance. For example:
AsyncHttpClient client = new AsyncHttpClient(); client.get("https://www.google.com", new AsyncHttpResponseHandler() { @Override public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) { System.out.println(response); } @Override public void onFailure(int statusCode, Header[] headers, byte[] responseBody, Throwable error) { error.printStackTrace(System.out); } });
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_MAX_CONNECTIONS |
static int |
DEFAULT_MAX_RETRIES |
static int |
DEFAULT_RETRY_SLEEP_TIME_MILLIS |
static int |
DEFAULT_SOCKET_BUFFER_SIZE |
static int |
DEFAULT_SOCKET_TIMEOUT |
static java.lang.String |
ENCODING_GZIP |
static java.lang.String |
HEADER_ACCEPT_ENCODING |
static java.lang.String |
HEADER_CONTENT_DISPOSITION |
static java.lang.String |
HEADER_CONTENT_ENCODING |
static java.lang.String |
HEADER_CONTENT_RANGE |
static java.lang.String |
HEADER_CONTENT_TYPE |
static LogInterface |
log |
static java.lang.String |
LOG_TAG |
Constructor and Description |
---|
AsyncHttpClient()
Creates a new AsyncHttpClient with default constructor arguments values
|
AsyncHttpClient(boolean fixNoHttpResponseException,
int httpPort,
int httpsPort)
Creates new AsyncHttpClient using given params
|
AsyncHttpClient(int httpPort)
Creates a new AsyncHttpClient.
|
AsyncHttpClient(int httpPort,
int httpsPort)
Creates a new AsyncHttpClient.
|
AsyncHttpClient(cz.msebera.android.httpclient.conn.scheme.SchemeRegistry schemeRegistry)
Creates a new AsyncHttpClient.
|
Modifier and Type | Method and Description |
---|---|
void |
addHeader(java.lang.String header,
java.lang.String value)
Sets headers that will be added to all requests this client makes (before sending).
|
static void |
allowRetryExceptionClass(java.lang.Class<?> cls) |
static void |
blockRetryExceptionClass(java.lang.Class<?> cls) |
void |
cancelAllRequests(boolean mayInterruptIfRunning)
Cancels all pending (or potentially active) requests.
|
void |
cancelRequests(android.content.Context context,
boolean mayInterruptIfRunning)
Cancels any pending (or potentially active) requests associated with the passed Context.
|
void |
cancelRequestsByTAG(java.lang.Object TAG,
boolean mayInterruptIfRunning)
Allows you to cancel all requests currently in queue or running, by set TAG,
if passed TAG is null, will not attempt to cancel any requests, if TAG is null
on RequestHandle, it cannot be canceled by this call
|
void |
clearCredentialsProvider()
Removes previously set auth credentials
|
protected cz.msebera.android.httpclient.conn.ClientConnectionManager |
createConnectionManager(cz.msebera.android.httpclient.conn.scheme.SchemeRegistry schemeRegistry,
cz.msebera.android.httpclient.params.BasicHttpParams httpParams)
Provided so it is easier for developers to provide custom ThreadSafeClientConnManager implementation
|
RequestHandle |
delete(android.content.Context context,
java.lang.String url,
cz.msebera.android.httpclient.Header[] headers,
RequestParams params,
ResponseHandlerInterface responseHandler)
Perform a HTTP DELETE request.
|
RequestHandle |
delete(android.content.Context context,
java.lang.String url,
cz.msebera.android.httpclient.Header[] headers,
ResponseHandlerInterface responseHandler)
Perform a HTTP DELETE request.
|
RequestHandle |
delete(android.content.Context context,
java.lang.String url,
cz.msebera.android.httpclient.HttpEntity entity,
java.lang.String contentType,
ResponseHandlerInterface responseHandler)
Perform a HTTP DELETE request and track the Android Context which initiated the request.
|
RequestHandle |
delete(android.content.Context context,
java.lang.String url,
ResponseHandlerInterface responseHandler)
Perform a HTTP DELETE request.
|
void |
delete(java.lang.String url,
RequestParams params,
AsyncHttpResponseHandler responseHandler)
Perform a HTTP DELETE request.
|
RequestHandle |
delete(java.lang.String url,
ResponseHandlerInterface responseHandler)
Perform a HTTP DELETE request.
|
static void |
endEntityViaReflection(cz.msebera.android.httpclient.HttpEntity entity)
This horrible hack is required on Android, due to implementation of BasicManagedEntity, which
doesn't chain call consumeContent on underlying wrapped HttpEntity
|
RequestHandle |
get(android.content.Context context,
java.lang.String url,
cz.msebera.android.httpclient.Header[] headers,
RequestParams params,
ResponseHandlerInterface responseHandler)
Perform a HTTP GET request and track the Android Context which initiated the request with
customized headers
|
RequestHandle |
get(android.content.Context context,
java.lang.String url,
cz.msebera.android.httpclient.HttpEntity entity,
java.lang.String contentType,
ResponseHandlerInterface responseHandler)
Perform a HTTP GET request and track the Android Context which initiated the request.
|
RequestHandle |
get(android.content.Context context,
java.lang.String url,
RequestParams params,
ResponseHandlerInterface responseHandler)
Perform a HTTP GET request and track the Android Context which initiated the request.
|
RequestHandle |
get(android.content.Context context,
java.lang.String url,
ResponseHandlerInterface responseHandler)
Perform a HTTP GET request without any parameters and track the Android Context which
initiated the request.
|
RequestHandle |
get(java.lang.String url,
RequestParams params,
ResponseHandlerInterface responseHandler)
Perform a HTTP GET request with parameters.
|
RequestHandle |
get(java.lang.String url,
ResponseHandlerInterface responseHandler)
Perform a HTTP GET request, without any parameters.
|
int |
getConnectTimeout()
Returns current connection timeout limit (milliseconds).
|
protected java.util.concurrent.ExecutorService |
getDefaultThreadPool()
Get the default threading pool to be used for this HTTP client.
|
cz.msebera.android.httpclient.client.HttpClient |
getHttpClient()
Get the underlying HttpClient instance.
|
cz.msebera.android.httpclient.protocol.HttpContext |
getHttpContext()
Get the underlying HttpContext instance.
|
int |
getLoggingLevel()
Retrieves current log level from underlying LogInterface instance.
|
LogInterface |
getLogInterface()
Will return current LogInterface used in AsyncHttpClient instance
|
int |
getMaxConnections()
Returns current limit of parallel connections
|
int |
getResponseTimeout()
Returns current response timeout limit (milliseconds).
|
java.util.concurrent.ExecutorService |
getThreadPool()
Returns the current executor service used.
|
protected java.net.URI |
getURI(java.lang.String url)
Returns a
URI instance for the specified, absolute URL string. |
static java.lang.String |
getUrlWithQueryString(boolean shouldEncodeUrl,
java.lang.String url,
RequestParams params)
Will encode url, if not disabled, and adds params on the end of it
|
RequestHandle |
head(android.content.Context context,
java.lang.String url,
cz.msebera.android.httpclient.Header[] headers,
RequestParams params,
ResponseHandlerInterface responseHandler)
Perform a HTTP HEAD request and track the Android Context which initiated the request with
customized headers
|
RequestHandle |
head(android.content.Context context,
java.lang.String url,
RequestParams params,
ResponseHandlerInterface responseHandler)
Perform a HTTP HEAD request and track the Android Context which initiated the request.
|
RequestHandle |
head(android.content.Context context,
java.lang.String url,
ResponseHandlerInterface responseHandler)
Perform a HTTP HEAD request without any parameters and track the Android Context which
initiated the request.
|
RequestHandle |
head(java.lang.String url,
RequestParams params,
ResponseHandlerInterface responseHandler)
Perform a HTTP HEAD request with parameters.
|
RequestHandle |
head(java.lang.String url,
ResponseHandlerInterface responseHandler)
Perform a HTTP HEAD request, without any parameters.
|
static boolean |
isInputStreamGZIPCompressed(java.io.PushbackInputStream inputStream)
Checks the InputStream if it contains GZIP compressed data
|
boolean |
isLoggingEnabled()
Returns logging enabled flag from underlying LogInterface instance
Default setting is logging enabled.
|
boolean |
isUrlEncodingEnabled() |
protected AsyncHttpRequest |
newAsyncHttpRequest(cz.msebera.android.httpclient.impl.client.DefaultHttpClient client,
cz.msebera.android.httpclient.protocol.HttpContext httpContext,
cz.msebera.android.httpclient.client.methods.HttpUriRequest uriRequest,
java.lang.String contentType,
ResponseHandlerInterface responseHandler,
android.content.Context context)
Instantiate a new asynchronous HTTP request for the passed parameters.
|
RequestHandle |
patch(android.content.Context context,
java.lang.String url,
cz.msebera.android.httpclient.Header[] headers,
cz.msebera.android.httpclient.HttpEntity entity,
java.lang.String contentType,
ResponseHandlerInterface responseHandler)
Perform a HTTP PATCH request and track the Android Context which initiated the request.
|
RequestHandle |
patch(android.content.Context context,
java.lang.String url,
cz.msebera.android.httpclient.HttpEntity entity,
java.lang.String contentType,
ResponseHandlerInterface responseHandler)
Perform a HTTP PATCH request and track the Android Context which initiated the request.
|
RequestHandle |
patch(android.content.Context context,
java.lang.String url,
RequestParams params,
ResponseHandlerInterface responseHandler)
Perform a HTTP PATCH request and track the Android Context which initiated the request.
|
RequestHandle |
patch(java.lang.String url,
RequestParams params,
ResponseHandlerInterface responseHandler)
Perform a HTTP PATCH request with parameters.
|
RequestHandle |
patch(java.lang.String url,
ResponseHandlerInterface responseHandler)
Perform a HTTP
request, without any parameters.
|
RequestHandle |
post(android.content.Context context,
java.lang.String url,
cz.msebera.android.httpclient.Header[] headers,
cz.msebera.android.httpclient.HttpEntity entity,
java.lang.String contentType,
ResponseHandlerInterface responseHandler)
Perform a HTTP POST request and track the Android Context which initiated the request.
|
RequestHandle |
post(android.content.Context context,
java.lang.String url,
cz.msebera.android.httpclient.Header[] headers,
RequestParams params,
java.lang.String contentType,
ResponseHandlerInterface responseHandler)
Perform a HTTP POST request and track the Android Context which initiated the request.
|
RequestHandle |
post(android.content.Context context,
java.lang.String url,
cz.msebera.android.httpclient.HttpEntity entity,
java.lang.String contentType,
ResponseHandlerInterface responseHandler)
Perform a HTTP POST request and track the Android Context which initiated the request.
|
RequestHandle |
post(android.content.Context context,
java.lang.String url,
RequestParams params,
ResponseHandlerInterface responseHandler)
Perform a HTTP POST request and track the Android Context which initiated the request.
|
RequestHandle |
post(java.lang.String url,
RequestParams params,
ResponseHandlerInterface responseHandler)
Perform a HTTP POST request with parameters.
|
RequestHandle |
post(java.lang.String url,
ResponseHandlerInterface responseHandler)
Perform a HTTP POST request, without any parameters.
|
RequestHandle |
put(android.content.Context context,
java.lang.String url,
cz.msebera.android.httpclient.Header[] headers,
cz.msebera.android.httpclient.HttpEntity entity,
java.lang.String contentType,
ResponseHandlerInterface responseHandler)
Perform a HTTP PUT request and track the Android Context which initiated the request.
|
RequestHandle |
put(android.content.Context context,
java.lang.String url,
cz.msebera.android.httpclient.HttpEntity entity,
java.lang.String contentType,
ResponseHandlerInterface responseHandler)
Perform a HTTP PUT request and track the Android Context which initiated the request.
|
RequestHandle |
put(android.content.Context context,
java.lang.String url,
RequestParams params,
ResponseHandlerInterface responseHandler)
Perform a HTTP PUT request and track the Android Context which initiated the request.
|
RequestHandle |
put(java.lang.String url,
RequestParams params,
ResponseHandlerInterface responseHandler)
Perform a HTTP PUT request with parameters.
|
RequestHandle |
put(java.lang.String url,
ResponseHandlerInterface responseHandler)
Perform a HTTP PUT request, without any parameters.
|
void |
removeAllHeaders()
Will, before sending, remove all headers currently present in AsyncHttpClient instance, which
applies on all requests this client makes
|
void |
removeHeader(java.lang.String header)
Remove header from all requests this client makes (before sending).
|
protected RequestHandle |
sendRequest(cz.msebera.android.httpclient.impl.client.DefaultHttpClient client,
cz.msebera.android.httpclient.protocol.HttpContext httpContext,
cz.msebera.android.httpclient.client.methods.HttpUriRequest uriRequest,
java.lang.String contentType,
ResponseHandlerInterface responseHandler,
android.content.Context context)
Puts a new request in queue as a new thread in pool to be executed
|
void |
setAuthenticationPreemptive(boolean isPreemptive)
Sets HttpRequestInterceptor which handles authorization in preemptive way, as workaround you
can use call `AsyncHttpClient.addHeader("Authorization","Basic base64OfUsernameAndPassword==")`
|
void |
setBasicAuth(java.lang.String username,
java.lang.String password)
Sets basic authentication for the request.
|
void |
setBasicAuth(java.lang.String username,
java.lang.String password,
cz.msebera.android.httpclient.auth.AuthScope scope)
Sets basic authentication for the request.
|
void |
setBasicAuth(java.lang.String username,
java.lang.String password,
cz.msebera.android.httpclient.auth.AuthScope scope,
boolean preemptive)
Sets basic authentication for the request.
|
void |
setBasicAuth(java.lang.String username,
java.lang.String password,
boolean preemptive)
Sets basic authentication for the request.
|
void |
setConnectTimeout(int value)
Set connection timeout limit (milliseconds).
|
void |
setCookieStore(cz.msebera.android.httpclient.client.CookieStore cookieStore)
Sets an optional CookieStore to use when making requests
|
void |
setCredentials(cz.msebera.android.httpclient.auth.AuthScope authScope,
cz.msebera.android.httpclient.auth.Credentials credentials) |
void |
setEnableRedirects(boolean enableRedirects) |
void |
setEnableRedirects(boolean enableRedirects,
boolean enableRelativeRedirects)
Circular redirects are enabled by default
|
void |
setEnableRedirects(boolean enableRedirects,
boolean enableRelativeRedirects,
boolean enableCircularRedirects)
Simple interface method, to enable or disable redirects.
|
void |
setLoggingEnabled(boolean loggingEnabled)
Will set logging enabled flag on underlying LogInterface instance.
|
void |
setLoggingLevel(int logLevel)
Sets log level to be used across all library default implementation
Default setting is VERBOSE log level.
|
void |
setLogInterface(LogInterface logInterfaceInstance)
Sets default LogInterface (similar to std Android Log util class) instance,
to be used in AsyncHttpClient instance
|
void |
setMaxConnections(int maxConnections)
Sets maximum limit of parallel connections
|
void |
setMaxRetriesAndTimeout(int retries,
int timeout)
Sets the maximum number of retries and timeout for a particular Request.
|
void |
setProxy(java.lang.String hostname,
int port)
Sets the Proxy by it's hostname and port
|
void |
setProxy(java.lang.String hostname,
int port,
java.lang.String username,
java.lang.String password)
Sets the Proxy by it's hostname,port,username and password
|
void |
setRedirectHandler(cz.msebera.android.httpclient.client.RedirectHandler customRedirectHandler)
Allows you to set custom RedirectHandler implementation, if the default provided doesn't suit
your needs
|
void |
setResponseTimeout(int value)
Set response timeout limit (milliseconds).
|
void |
setSSLSocketFactory(cz.msebera.android.httpclient.conn.ssl.SSLSocketFactory sslSocketFactory)
Sets the SSLSocketFactory to user when making requests.
|
void |
setThreadPool(java.util.concurrent.ExecutorService threadPool)
Overrides the threadpool implementation used when queuing/pooling requests.
|
void |
setTimeout(int value)
Set both the connection and socket timeouts.
|
void |
setURLEncodingEnabled(boolean enabled)
Sets state of URL encoding feature, see bug #227, this method allows you to turn off and on
this auto-magic feature on-demand.
|
void |
setUserAgent(java.lang.String userAgent)
Sets the User-Agent header to be sent with each request.
|
static void |
silentCloseInputStream(java.io.InputStream is)
A utility function to close an input stream without raising an exception.
|
static void |
silentCloseOutputStream(java.io.OutputStream os)
A utility function to close an output stream without raising an exception.
|
public static final java.lang.String LOG_TAG
public static final java.lang.String HEADER_CONTENT_TYPE
public static final java.lang.String HEADER_CONTENT_RANGE
public static final java.lang.String HEADER_CONTENT_ENCODING
public static final java.lang.String HEADER_CONTENT_DISPOSITION
public static final java.lang.String HEADER_ACCEPT_ENCODING
public static final java.lang.String ENCODING_GZIP
public static final int DEFAULT_MAX_CONNECTIONS
public static final int DEFAULT_SOCKET_TIMEOUT
public static final int DEFAULT_MAX_RETRIES
public static final int DEFAULT_RETRY_SLEEP_TIME_MILLIS
public static final int DEFAULT_SOCKET_BUFFER_SIZE
public static LogInterface log
public AsyncHttpClient()
public AsyncHttpClient(int httpPort)
httpPort
- non-standard HTTP-only portpublic AsyncHttpClient(int httpPort, int httpsPort)
httpPort
- non-standard HTTP-only porthttpsPort
- non-standard HTTPS-only portpublic AsyncHttpClient(boolean fixNoHttpResponseException, int httpPort, int httpsPort)
fixNoHttpResponseException
- Whether to fix issue or not, by omitting SSL verificationhttpPort
- HTTP port to be used, must be greater than 0httpsPort
- HTTPS port to be used, must be greater than 0public AsyncHttpClient(cz.msebera.android.httpclient.conn.scheme.SchemeRegistry schemeRegistry)
schemeRegistry
- SchemeRegistry to be usedpublic static void allowRetryExceptionClass(java.lang.Class<?> cls)
public static void blockRetryExceptionClass(java.lang.Class<?> cls)
public static java.lang.String getUrlWithQueryString(boolean shouldEncodeUrl, java.lang.String url, RequestParams params)
url
- String with URL, should be valid URL without paramsparams
- RequestParams to be appended on the end of URLshouldEncodeUrl
- whether url should be encoded (replaces spaces with %20)public static boolean isInputStreamGZIPCompressed(java.io.PushbackInputStream inputStream) throws java.io.IOException
inputStream
- InputStream to be checkedjava.io.IOException
- if read from inputStream failspublic static void silentCloseInputStream(java.io.InputStream is)
is
- input stream to close safelypublic static void silentCloseOutputStream(java.io.OutputStream os)
os
- output stream to close safelypublic static void endEntityViaReflection(cz.msebera.android.httpclient.HttpEntity entity)
entity
- HttpEntity, may be nullpublic cz.msebera.android.httpclient.client.HttpClient getHttpClient()
public cz.msebera.android.httpclient.protocol.HttpContext getHttpContext()
public boolean isLoggingEnabled()
public void setLoggingEnabled(boolean loggingEnabled)
loggingEnabled
- whether the logging should be enabled or notpublic int getLoggingLevel()
public void setLoggingLevel(int logLevel)
logLevel
- int log level, either from LogInterface interface or from Log
public LogInterface getLogInterface()
public void setLogInterface(LogInterface logInterfaceInstance)
logInterfaceInstance
- LogInterface instance, if null, nothing is donepublic void setCookieStore(cz.msebera.android.httpclient.client.CookieStore cookieStore)
cookieStore
- The CookieStore implementation to use, usually an instance of PersistentCookieStore
public java.util.concurrent.ExecutorService getThreadPool()
public void setThreadPool(java.util.concurrent.ExecutorService threadPool)
threadPool
- an instance of ExecutorService
to use for queuing/pooling
requests.protected java.util.concurrent.ExecutorService getDefaultThreadPool()
protected cz.msebera.android.httpclient.conn.ClientConnectionManager createConnectionManager(cz.msebera.android.httpclient.conn.scheme.SchemeRegistry schemeRegistry, cz.msebera.android.httpclient.params.BasicHttpParams httpParams)
schemeRegistry
- SchemeRegistry, usually provided by getDefaultSchemeRegistry(boolean, int, int)
httpParams
- BasicHttpParamspublic void setEnableRedirects(boolean enableRedirects, boolean enableRelativeRedirects, boolean enableCircularRedirects)
Default setting is to disallow redirects.
enableRedirects
- booleanenableRelativeRedirects
- booleanenableCircularRedirects
- booleanpublic void setEnableRedirects(boolean enableRedirects, boolean enableRelativeRedirects)
enableRedirects
- booleanenableRelativeRedirects
- booleansetEnableRedirects(boolean, boolean, boolean)
public void setEnableRedirects(boolean enableRedirects)
enableRedirects
- booleansetEnableRedirects(boolean, boolean, boolean)
public void setRedirectHandler(cz.msebera.android.httpclient.client.RedirectHandler customRedirectHandler)
customRedirectHandler
- RedirectHandler instanceMyRedirectHandler
public void setUserAgent(java.lang.String userAgent)
userAgent
- the string to use in the User-Agent header.public int getMaxConnections()
public void setMaxConnections(int maxConnections)
maxConnections
- maximum parallel connections, must be at least 1public void setTimeout(int value)
value
- the connect/socket timeout in milliseconds, at least 1 secondsetConnectTimeout(int)
,
setResponseTimeout(int)
public int getConnectTimeout()
public void setConnectTimeout(int value)
value
- Connection timeout in milliseconds, minimal value is 1000 (1 second).public int getResponseTimeout()
public void setResponseTimeout(int value)
value
- Response timeout in milliseconds, minimal value is 1000 (1 second).public void setProxy(java.lang.String hostname, int port)
hostname
- the hostname (IP or DNS name)port
- the port number. -1 indicates the scheme default port.public void setProxy(java.lang.String hostname, int port, java.lang.String username, java.lang.String password)
hostname
- the hostname (IP or DNS name)port
- the port number. -1 indicates the scheme default port.username
- the usernamepassword
- the passwordpublic void setSSLSocketFactory(cz.msebera.android.httpclient.conn.ssl.SSLSocketFactory sslSocketFactory)
sslSocketFactory
- the socket factory to use for https requests.public void setMaxRetriesAndTimeout(int retries, int timeout)
retries
- maximum number of retries per requesttimeout
- sleep between retries in millisecondspublic void removeAllHeaders()
public void addHeader(java.lang.String header, java.lang.String value)
header
- the name of the headervalue
- the contents of the headerpublic void removeHeader(java.lang.String header)
header
- the name of the headerpublic void setBasicAuth(java.lang.String username, java.lang.String password)
username
- Basic Auth usernamepassword
- Basic Auth passwordpublic void setBasicAuth(java.lang.String username, java.lang.String password, boolean preemptive)
username
- Basic Auth usernamepassword
- Basic Auth passwordpreemptive
- sets authorization in preemptive mannerpublic void setBasicAuth(java.lang.String username, java.lang.String password, cz.msebera.android.httpclient.auth.AuthScope scope)
username
- Basic Auth usernamepassword
- Basic Auth passwordscope
- - an AuthScope objectpublic void setBasicAuth(java.lang.String username, java.lang.String password, cz.msebera.android.httpclient.auth.AuthScope scope, boolean preemptive)
username
- Basic Auth usernamepassword
- Basic Auth passwordscope
- an AuthScope objectpreemptive
- sets authorization in preemptive mannerpublic void setCredentials(cz.msebera.android.httpclient.auth.AuthScope authScope, cz.msebera.android.httpclient.auth.Credentials credentials)
public void setAuthenticationPreemptive(boolean isPreemptive)
isPreemptive
- whether the authorization is processed in preemptive waypublic void clearCredentialsProvider()
public void cancelRequests(android.content.Context context, boolean mayInterruptIfRunning)
Note: This will only affect requests which were created with a non-null android Context. This method is intended to be used in the onDestroy method of your android activities to destroy all requests which are no longer required.
context
- the android Context instance associated to the request.mayInterruptIfRunning
- specifies if active requests should be cancelled along with
pending requests.public void cancelAllRequests(boolean mayInterruptIfRunning)
Note: This will only affect requests which were created with a non-null android Context. This method is intended to be used in the onDestroy method of your android activities to destroy all requests which are no longer required.
mayInterruptIfRunning
- specifies if active requests should be cancelled along with
pending requests.public void cancelRequestsByTAG(java.lang.Object TAG, boolean mayInterruptIfRunning)
TAG
- TAG to be matched in RequestHandlemayInterruptIfRunning
- specifies if active requests should be cancelled along with
pending requests.public RequestHandle head(java.lang.String url, ResponseHandlerInterface responseHandler)
url
- the URL to send the request to.responseHandler
- the response handler instance that should handle the response.public RequestHandle head(java.lang.String url, RequestParams params, ResponseHandlerInterface responseHandler)
url
- the URL to send the request to.params
- additional HEAD parameters to send with the request.responseHandler
- the response handler instance that should handle the response.public RequestHandle head(android.content.Context context, java.lang.String url, ResponseHandlerInterface responseHandler)
context
- the Android Context which initiated the request.url
- the URL to send the request to.responseHandler
- the response handler instance that should handle the response.public RequestHandle head(android.content.Context context, java.lang.String url, RequestParams params, ResponseHandlerInterface responseHandler)
context
- the Android Context which initiated the request.url
- the URL to send the request to.params
- additional HEAD parameters to send with the request.responseHandler
- the response handler instance that should handle the response.public RequestHandle head(android.content.Context context, java.lang.String url, cz.msebera.android.httpclient.Header[] headers, RequestParams params, ResponseHandlerInterface responseHandler)
context
- Context to execute request againsturl
- the URL to send the request to.headers
- set headers only for this requestparams
- additional HEAD parameters to send with the request.responseHandler
- the response handler instance that should handle the response.public RequestHandle get(java.lang.String url, ResponseHandlerInterface responseHandler)
url
- the URL to send the request to.responseHandler
- the response handler instance that should handle the response.public RequestHandle get(java.lang.String url, RequestParams params, ResponseHandlerInterface responseHandler)
url
- the URL to send the request to.params
- additional GET parameters to send with the request.responseHandler
- the response handler instance that should handle the response.public RequestHandle get(android.content.Context context, java.lang.String url, ResponseHandlerInterface responseHandler)
context
- the Android Context which initiated the request.url
- the URL to send the request to.responseHandler
- the response handler instance that should handle the response.public RequestHandle get(android.content.Context context, java.lang.String url, RequestParams params, ResponseHandlerInterface responseHandler)
context
- the Android Context which initiated the request.url
- the URL to send the request to.params
- additional GET parameters to send with the request.responseHandler
- the response handler instance that should handle the response.public RequestHandle get(android.content.Context context, java.lang.String url, cz.msebera.android.httpclient.Header[] headers, RequestParams params, ResponseHandlerInterface responseHandler)
context
- Context to execute request againsturl
- the URL to send the request to.headers
- set headers only for this requestparams
- additional GET parameters to send with the request.responseHandler
- the response handler instance that should handle the response.public RequestHandle get(android.content.Context context, java.lang.String url, cz.msebera.android.httpclient.HttpEntity entity, java.lang.String contentType, ResponseHandlerInterface responseHandler)
context
- the Android Context which initiated the request.url
- the URL to send the request to.entity
- a raw HttpEntity
to send with the request, for
example, use this to send string/json/xml payloads to a server by
passing a StringEntity
.contentType
- the content type of the payload you are sending, for example
application/json if sending a json payload.responseHandler
- the response ha ndler instance that should handle the response.public RequestHandle post(java.lang.String url, ResponseHandlerInterface responseHandler)
url
- the URL to send the request to.responseHandler
- the response handler instance that should handle the response.public RequestHandle post(java.lang.String url, RequestParams params, ResponseHandlerInterface responseHandler)
url
- the URL to send the request to.params
- additional POST parameters or files to send with the request.responseHandler
- the response handler instance that should handle the response.public RequestHandle post(android.content.Context context, java.lang.String url, RequestParams params, ResponseHandlerInterface responseHandler)
context
- the Android Context which initiated the request.url
- the URL to send the request to.params
- additional POST parameters or files to send with the request.responseHandler
- the response handler instance that should handle the response.public RequestHandle post(android.content.Context context, java.lang.String url, cz.msebera.android.httpclient.HttpEntity entity, java.lang.String contentType, ResponseHandlerInterface responseHandler)
context
- the Android Context which initiated the request.url
- the URL to send the request to.entity
- a raw HttpEntity
to send with the request, for
example, use this to send string/json/xml payloads to a server by
passing a StringEntity
.contentType
- the content type of the payload you are sending, for example
application/json if sending a json payload.responseHandler
- the response ha ndler instance that should handle the response.public RequestHandle post(android.content.Context context, java.lang.String url, cz.msebera.android.httpclient.Header[] headers, RequestParams params, java.lang.String contentType, ResponseHandlerInterface responseHandler)
context
- the Android Context which initiated the request.url
- the URL to send the request to.headers
- set headers only for this requestparams
- additional POST parameters to send with the request.contentType
- the content type of the payload you are sending, for example
application/json if sending a json payload.responseHandler
- the response handler instance that should handle the response.public RequestHandle post(android.content.Context context, java.lang.String url, cz.msebera.android.httpclient.Header[] headers, cz.msebera.android.httpclient.HttpEntity entity, java.lang.String contentType, ResponseHandlerInterface responseHandler)
context
- the Android Context which initiated the request.url
- the URL to send the request to.headers
- set headers only for this requestentity
- a raw HttpEntity
to send with the request, for example, use
this to send string/json/xml payloads to a server by passing a StringEntity
.contentType
- the content type of the payload you are sending, for example
application/json if sending a json payload.responseHandler
- the response handler instance that should handle the response.public RequestHandle put(java.lang.String url, ResponseHandlerInterface responseHandler)
url
- the URL to send the request to.responseHandler
- the response handler instance that should handle the response.public RequestHandle put(java.lang.String url, RequestParams params, ResponseHandlerInterface responseHandler)
url
- the URL to send the request to.params
- additional PUT parameters or files to send with the request.responseHandler
- the response handler instance that should handle the response.public RequestHandle put(android.content.Context context, java.lang.String url, RequestParams params, ResponseHandlerInterface responseHandler)
context
- the Android Context which initiated the request.url
- the URL to send the request to.params
- additional PUT parameters or files to send with the request.responseHandler
- the response handler instance that should handle the response.public RequestHandle put(android.content.Context context, java.lang.String url, cz.msebera.android.httpclient.HttpEntity entity, java.lang.String contentType, ResponseHandlerInterface responseHandler)
context
- the Android Context which initiated the request.url
- the URL to send the request to.entity
- a raw HttpEntity
to send with the request, for example, use
this to send string/json/xml payloads to a server by passing a StringEntity
.contentType
- the content type of the payload you are sending, for example
application/json if sending a json payload.responseHandler
- the response handler instance that should handle the response.public RequestHandle put(android.content.Context context, java.lang.String url, cz.msebera.android.httpclient.Header[] headers, cz.msebera.android.httpclient.HttpEntity entity, java.lang.String contentType, ResponseHandlerInterface responseHandler)
context
- the Android Context which initiated the request.url
- the URL to send the request to.headers
- set one-time headers for this requestentity
- a raw HttpEntity
to send with the request, for example, use
this to send string/json/xml payloads to a server by passing a StringEntity
.contentType
- the content type of the payload you are sending, for example
application/json if sending a json payload.responseHandler
- the response handler instance that should handle the response.public RequestHandle patch(java.lang.String url, ResponseHandlerInterface responseHandler)
url
- the URL to send the request to.responseHandler
- the response handler instance that should handle the response.public RequestHandle patch(java.lang.String url, RequestParams params, ResponseHandlerInterface responseHandler)
url
- the URL to send the request to.params
- additional PUT parameters or files to send with the request.responseHandler
- the response handler instance that should handle the response.public RequestHandle patch(android.content.Context context, java.lang.String url, RequestParams params, ResponseHandlerInterface responseHandler)
context
- the Android Context which initiated the request.url
- the URL to send the request to.params
- additional PUT parameters or files to send with the request.responseHandler
- the response handler instance that should handle the response.public RequestHandle patch(android.content.Context context, java.lang.String url, cz.msebera.android.httpclient.HttpEntity entity, java.lang.String contentType, ResponseHandlerInterface responseHandler)
context
- the Android Context which initiated the request.url
- the URL to send the request to.responseHandler
- the response handler instance that should handle the response.entity
- a raw HttpEntity
to send with the request, for example, use
this to send string/json/xml payloads to a server by passing a StringEntity
contentType
- the content type of the payload you are sending, for example
"application/json" if sending a json payload.public RequestHandle patch(android.content.Context context, java.lang.String url, cz.msebera.android.httpclient.Header[] headers, cz.msebera.android.httpclient.HttpEntity entity, java.lang.String contentType, ResponseHandlerInterface responseHandler)
context
- the Android Context which initiated the request.url
- the URL to send the request to.headers
- set one-time headers for this requestentity
- a raw HttpEntity
to send with the request, for example, use
this to send string/json/xml payloads to a server by passing a StringEntity
.contentType
- the content type of the payload you are sending, for example
application/json if sending a json payload.responseHandler
- the response handler instance that should handle the response.public RequestHandle delete(java.lang.String url, ResponseHandlerInterface responseHandler)
url
- the URL to send the request to.responseHandler
- the response handler instance that should handle the response.public RequestHandle delete(android.content.Context context, java.lang.String url, ResponseHandlerInterface responseHandler)
context
- the Android Context which initiated the request.url
- the URL to send the request to.responseHandler
- the response handler instance that should handle the response.public RequestHandle delete(android.content.Context context, java.lang.String url, cz.msebera.android.httpclient.Header[] headers, ResponseHandlerInterface responseHandler)
context
- the Android Context which initiated the request.url
- the URL to send the request to.headers
- set one-time headers for this requestresponseHandler
- the response handler instance that should handle the response.public void delete(java.lang.String url, RequestParams params, AsyncHttpResponseHandler responseHandler)
url
- the URL to send the request to.params
- additional DELETE parameters or files to send with the request.responseHandler
- the response handler instance that should handle the response.public RequestHandle delete(android.content.Context context, java.lang.String url, cz.msebera.android.httpclient.Header[] headers, RequestParams params, ResponseHandlerInterface responseHandler)
context
- the Android Context which initiated the request.url
- the URL to send the request to.headers
- set one-time headers for this requestparams
- additional DELETE parameters or files to send along with requestresponseHandler
- the response handler instance that should handle the response.public RequestHandle delete(android.content.Context context, java.lang.String url, cz.msebera.android.httpclient.HttpEntity entity, java.lang.String contentType, ResponseHandlerInterface responseHandler)
context
- the Android Context which initiated the request.url
- the URL to send the request to.entity
- a raw HttpEntity
to send with the request, for
example, use this to send string/json/xml payloads to a server by
passing a StringEntity
.contentType
- the content type of the payload you are sending, for example
application/json if sending a json payload.responseHandler
- the response ha ndler instance that should handle the response.protected AsyncHttpRequest newAsyncHttpRequest(cz.msebera.android.httpclient.impl.client.DefaultHttpClient client, cz.msebera.android.httpclient.protocol.HttpContext httpContext, cz.msebera.android.httpclient.client.methods.HttpUriRequest uriRequest, java.lang.String contentType, ResponseHandlerInterface responseHandler, android.content.Context context)
client
- HttpClient to be used for request, can differ in single requestscontentType
- MIME body type, for POST and PUT requests, may be nullcontext
- Context of Android application, to hold the reference of requesthttpContext
- HttpContext in which the request will be executedresponseHandler
- ResponseHandler or its subclass to put the response intouriRequest
- instance of HttpUriRequest, which means it must be of HttpDelete,
HttpPost, HttpGet, HttpPut, etc.protected RequestHandle sendRequest(cz.msebera.android.httpclient.impl.client.DefaultHttpClient client, cz.msebera.android.httpclient.protocol.HttpContext httpContext, cz.msebera.android.httpclient.client.methods.HttpUriRequest uriRequest, java.lang.String contentType, ResponseHandlerInterface responseHandler, android.content.Context context)
client
- HttpClient to be used for request, can differ in single requestscontentType
- MIME body type, for POST and PUT requests, may be nullcontext
- Context of Android application, to hold the reference of requesthttpContext
- HttpContext in which the request will be executedresponseHandler
- ResponseHandler or its subclass to put the response intouriRequest
- instance of HttpUriRequest, which means it must be of HttpDelete,
HttpPost, HttpGet, HttpPut, etc.protected java.net.URI getURI(java.lang.String url)
URI
instance for the specified, absolute URL string.url
- absolute URL string, containing scheme, host and pathpublic void setURLEncodingEnabled(boolean enabled)
enabled
- desired state of featurepublic boolean isUrlEncodingEnabled()