|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectoak.http.OkHttpTool
public class OkHttpTool
This is a utility class for abstracting commonly used OkHttp methods Created by ericrichardson on 1/6/14.
| Field Summary | |
|---|---|
static String |
DELETE
|
static String |
GET
|
static String |
POST
|
static String |
PUT
|
| Constructor Summary | |
|---|---|
OkHttpTool()
Constructor with no Context. |
|
OkHttpTool(android.content.Context context)
Constructor with a Context to install a ResponseCache |
|
| Method Summary | |
|---|---|
HttpURLConnection |
delete(String url)
Basic DELETE Request |
HttpURLConnection |
get(String url)
Basic GET Request |
BufferedReader |
getBufferedInputReader(HttpURLConnection connection)
|
Map<String,String> |
getDefaultHeaders()
Returns the default request headers |
HttpURLConnection |
post(String url,
org.apache.http.entity.StringEntity entity)
Basic POST Request |
HttpURLConnection |
put(String url,
org.apache.http.entity.StringEntity entity)
Basic PUT Request |
void |
setCertValidationDisabled(boolean isDisabled)
Deprecated. |
void |
setConnectTimeout(long timeout)
Set's OkHttpClients Connect Timeout. |
void |
setDefaultHeaders(Map<String,String> defaultHeaders)
Set default headers to set on all Http Requests |
void |
setPreEmptiveBasicAuth(String targetHost,
String username,
String password)
Sets Basic Auth for all requests |
void |
setReadTimeout(long timeout)
Set's OkHttpClients Read Timeout. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final String PUT
public static final String POST
public static final String GET
public static final String DELETE
| Constructor Detail |
|---|
public OkHttpTool(android.content.Context context)
context - used to install ResponseCachepublic OkHttpTool()
| Method Detail |
|---|
public void setReadTimeout(long timeout)
timeout - Time is Milliseconds to wait until Timeoutpublic void setConnectTimeout(long timeout)
timeout - Time is Milliseconds to wait until Timeoutpublic void setDefaultHeaders(Map<String,String> defaultHeaders)
defaultHeaders - Map of http headerspublic Map<String,String> getDefaultHeaders()
public HttpURLConnection get(String url)
throws IOException
url - URL to send GET request
IOException
public HttpURLConnection post(String url,
org.apache.http.entity.StringEntity entity)
throws IOException
url - URL to send POST requestentity - StringEntity to send as the body of the POST request
IOException
public HttpURLConnection put(String url,
org.apache.http.entity.StringEntity entity)
throws IOException
url - URL to send PUT requestentity - StringEntity to send as the body of the PUT request
IOException
public HttpURLConnection delete(String url)
throws IOException
url - URL to send DELETE request
IOException@Deprecated public void setCertValidationDisabled(boolean isDisabled)
isDisabled -
public void setPreEmptiveBasicAuth(String targetHost,
String username,
String password)
targetHost - Host to authenticate tousername - Username of userpassword - password as user
public BufferedReader getBufferedInputReader(HttpURLConnection connection)
throws IOException
connection - HttpUrlConnection to get a reader from
IOException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||