|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.jakewharton.apibuilder.ApiService
public class ApiService
HTTP method execution.
Parts of the code for this class are from Nabeel Mukhtar's github-java-sdk library.
Field Summary | |
---|---|
protected static String |
CONTENT_ENCODING
|
Constructor Summary | |
---|---|
ApiService()
|
Method Summary | |
---|---|
protected void |
acceptGzip()
Add the HTTP header denoting that we accept GZIP. |
void |
addRequestHeader(String name,
String value)
Add an HTTP request header. |
protected static void |
closeConnection(HttpURLConnection connection)
Close the specified connection. |
protected static void |
closeStream(InputStream is)
Close the specified stream. |
protected static String |
convertStreamToString(InputStream is)
Read an entire stream to end and assemble in a string. |
protected InputStream |
executeDelete(String apiUrl)
Execute the URL using HTTP DELETE. |
protected InputStream |
executeDelete(String apiUrl,
int expected)
Execute the URL using HTTP DELETE. |
protected InputStream |
executeGet(String apiUrl)
Execute the URL using HTTP GET. |
protected InputStream |
executeGet(String apiUrl,
int expected)
Execute the URL using HTTP GET. |
protected InputStream |
executeMethod(String apiUrl,
String content,
String contentType,
String method,
int expected)
Execute URL using the specified HTTP method name. |
protected InputStream |
executePost(String apiUrl,
Map<String,String> parameters)
Execute the URL using HTTP POST. |
protected InputStream |
executePost(String apiUrl,
Map<String,String> parameters,
int expected)
Execute the URL using HTTP POST |
int |
getConnectTimeout()
Get connection timeout value. |
protected static String |
getParametersString(Map<String,String> parameters)
Assemble a parameter string from a mapping. |
int |
getReadTimeout()
Get read timeout value. |
protected static InputStream |
getWrappedInputStream(InputStream is,
boolean gzip)
Properly wrap the stream accounting for GZIP. |
void |
removeRequestHeader(String name)
Remove an HTTP request header. |
void |
setConnectTimeout(int connectTimeout)
Set the connection timeout value. |
void |
setReadTimeout(int readTimeout)
Set read timeout value. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static final String CONTENT_ENCODING
Constructor Detail |
---|
public ApiService()
Method Detail |
---|
protected void acceptGzip()
public void addRequestHeader(String name, String value)
name
- Header name.value
- Header value.public void removeRequestHeader(String name)
name
- Header name.public int getConnectTimeout()
public void setConnectTimeout(int connectTimeout)
connectTimeout
- Timeout (in milliseconds).public int getReadTimeout()
public void setReadTimeout(int readTimeout)
readTimeout
- Timeout (in milliseconds).protected InputStream executeGet(String apiUrl)
apiUrl
- URL.
protected InputStream executeGet(String apiUrl, int expected)
apiUrl
- URL.expected
- Expected HTTP response code.
protected InputStream executePost(String apiUrl, Map<String,String> parameters)
apiUrl
- URL.parameters
- POST body parameters.
protected InputStream executePost(String apiUrl, Map<String,String> parameters, int expected)
apiUrl
- URL.parameters
- POST body parameters.expected
- Excepted HTTP response code.
protected InputStream executeDelete(String apiUrl)
apiUrl
- URL.
protected InputStream executeDelete(String apiUrl, int expected)
apiUrl
- URL.expected
- Expected HTTP response code.
protected InputStream executeMethod(String apiUrl, String content, String contentType, String method, int expected)
apiUrl
- URL.content
- Request body content.contentType
- Request body content type.method
- HTTP method name.expected
- Expected HTTP response code.
protected static String getParametersString(Map<String,String> parameters)
parameters
- Mapping of parameter names to values.
protected static void closeStream(InputStream is)
is
- Stream to close.protected static void closeConnection(HttpURLConnection connection)
connection
- Connection to close.protected static InputStream getWrappedInputStream(InputStream is, boolean gzip) throws IOException
is
- Stream to wrap.gzip
- Whether or not to include a GZIP wrapper.
IOException
protected static String convertStreamToString(InputStream is)
is
- Stream to read.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |