public class HttpClient<T extends HttpClient>
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
protected java.lang.String |
mBaseUrl |
protected java.util.concurrent.ExecutorService |
mThreadPool |
| Constructor and Description |
|---|
HttpClient() |
| Modifier and Type | Method and Description |
|---|---|
void |
get(java.lang.String path,
HttpResponseCallback callback)
Make a HTTP GET request to using the base url and path provided.
|
protected java.net.HttpURLConnection |
init(java.lang.String url) |
protected java.lang.String |
parseResponse(java.net.HttpURLConnection connection) |
java.lang.String |
post(java.lang.String path,
java.lang.String data)
Performs a synchronous post request.
|
void |
post(java.lang.String path,
java.lang.String data,
HttpResponseCallback callback)
Make a HTTP POST request using the base url and path provided.
|
T |
setBaseUrl(java.lang.String baseUrl) |
T |
setConnectTimeout(int timeout) |
T |
setReadTimeout(int timeout) |
T |
setSSLSocketFactory(javax.net.ssl.SSLSocketFactory sslSocketFactory) |
T |
setUserAgent(java.lang.String userAgent) |
protected void |
writeOutputStream(java.io.OutputStream outputStream,
java.lang.String data) |
protected final java.util.concurrent.ExecutorService mThreadPool
protected java.lang.String mBaseUrl
public T setUserAgent(java.lang.String userAgent)
userAgent - the user agent to be sent with all http requests.HttpClient for method chaining.public T setSSLSocketFactory(javax.net.ssl.SSLSocketFactory sslSocketFactory)
sslSocketFactory - the SSLSocketFactory to use for all https requests.HttpClient for method chaining.public T setBaseUrl(java.lang.String baseUrl)
baseUrl - the base url to use when only a path is supplied to
get(String, HttpResponseCallback) or post(String, String, HttpResponseCallback)HttpClient for method chaining.public T setConnectTimeout(int timeout)
timeout - the time in milliseconds to wait for a connection before timing out.HttpClient for method chaining.public T setReadTimeout(int timeout)
timeout - the time in milliseconds to read a response from the server before timing out.HttpClient for method chaining.public void get(java.lang.String path,
HttpResponseCallback callback)
path - The path or url to request from the server via GETcallback - The HttpResponseCallback to receive the response or error.public void post(java.lang.String path,
java.lang.String data,
HttpResponseCallback callback)
path - The path or url to request from the server via HTTP POSTdata - The body of the POST requestcallback - The HttpResponseCallback to receive the response or error.public java.lang.String post(java.lang.String path,
java.lang.String data)
throws java.lang.Exception
path - the path or url to request from the server via HTTP POSTdata - the body of the post requestjava.lang.Exceptionpost(String, String, HttpResponseCallback)protected java.net.HttpURLConnection init(java.lang.String url)
throws java.io.IOException
java.io.IOExceptionprotected void writeOutputStream(java.io.OutputStream outputStream,
java.lang.String data)
throws java.io.IOException
java.io.IOExceptionprotected java.lang.String parseResponse(java.net.HttpURLConnection connection)
throws java.lang.Exception
java.lang.Exception