public class AsyncOkHttpClient
extends java.lang.Object
| Constructor and Description |
|---|
AsyncOkHttpClient() |
| Modifier and Type | Method and Description |
|---|---|
void |
addHeader(java.lang.String key,
java.lang.String value)
Add a header on the request,
please note a null header key of a null header value
will quietly be ignored from the final headers
ensure that passe parameter is not null
|
void |
delete(java.lang.String url,
AsyncHttpResponse response)
Execute a DELETE request
|
void |
delete(java.lang.String url,
RequestParams params,
AsyncHttpResponse response)
Execute a DELETE request
|
void |
get(java.lang.String url,
AsyncHttpResponse response)
Execute a GET request
|
void |
get(java.lang.String url,
RequestParams params,
AsyncHttpResponse response)
Execute a GET request
|
OkHttpClient |
getOkHttpClient()
Return a instance used for the requests on this client
|
void |
post(java.lang.String url,
AsyncHttpResponse response)
Execute a POST request
|
void |
post(java.lang.String url,
RequestParams params,
AsyncHttpResponse response)
Execute a POST request
|
void |
put(java.lang.String url,
AsyncHttpResponse response)
Execute a PUT request
|
void |
put(java.lang.String url,
RequestParams params,
AsyncHttpResponse response)
Execute a PUT request
|
protected void |
sendRequest(OkHttpClient client,
java.lang.String url,
AsyncHttpResponse response,
RequestParams params,
java.lang.String requestMethod)
Send the specific request for the request response
|
void |
setConnectionTimeut(long timeout,
java.util.concurrent.TimeUnit unit)
Set the connection timeout for the requests based on the time unit
0 means no timeout
|
void |
setReadTieout(long timeout,
java.util.concurrent.TimeUnit unit)
Set the read timeout for the requests based on the time unit
0 means no timeout
|
void |
setThreadPool(java.util.concurrent.ThreadPoolExecutor threadPool)
Set the executor to execute the requests
on the most use cases this is not necessary
but is a good choice for make unit tests
|
public OkHttpClient getOkHttpClient()
com.squareup.okhttp.OkHttpClientpublic void addHeader(java.lang.String key,
java.lang.String value)
key - the header namevalue - the header valuepublic void setThreadPool(java.util.concurrent.ThreadPoolExecutor threadPool)
threadPool - a new thread pool for execute the incoming requestspublic void setConnectionTimeut(long timeout,
java.util.concurrent.TimeUnit unit)
timeout - a new timeout valueunit - the unit for the timeoutTimeUnitpublic void setReadTieout(long timeout,
java.util.concurrent.TimeUnit unit)
timeout - a new timeout valueunit - the unit for the timeoutTimeUnitprotected void sendRequest(OkHttpClient client,
java.lang.String url,
AsyncHttpResponse response,
RequestParams params,
java.lang.String requestMethod)
client - the client for execute the requesturl - the url for executeresponse - the response handler for this requestparams - the request parameters null parameters means no parametersrequestMethod - the request method for requestsAsyncHttpRequest,
RequestMethodpublic void get(java.lang.String url,
AsyncHttpResponse response)
url - the url for executeresponse - the response handler to manage the resultspublic void get(java.lang.String url,
RequestParams params,
AsyncHttpResponse response)
url - the url for executeparams - the request parameters null parameters means no parametersresponse - the response handler to manage the resultspublic void post(java.lang.String url,
AsyncHttpResponse response)
url - the url for executeresponse - the response handler to manage the resultspublic void post(java.lang.String url,
RequestParams params,
AsyncHttpResponse response)
url - the url for executeparams - the request parameters null parameters means no parametersresponse - the response handler to manage the resultspublic void put(java.lang.String url,
RequestParams params,
AsyncHttpResponse response)
url - the url for executeparams - the request parameters null parameters means no parametersresponse - the response handler to manage the resultspublic void put(java.lang.String url,
AsyncHttpResponse response)
url - the url for executeresponse - the response handler to manage the resultspublic void delete(java.lang.String url,
RequestParams params,
AsyncHttpResponse response)
url - the url for executeparams - the request parameters null parameters means no parametersresponse - the response handler to manage the resultspublic void delete(java.lang.String url,
AsyncHttpResponse response)
url - the url for executeresponse - the response handler to manage the results