|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface HTTPProtocol
A facade interface to interact with a plain HTTP server.
This interface provides a mean for plain HTTP conversation. That is, issueing HTTP requests both through GET and POST methods, handling gzip encoding/decoding if supported by the server, URL encoding for query string parameters, and handling HTTP authentication.
Nested Class Summary | |
---|---|
static interface |
HTTPProtocol.POSTCallBack
|
Method Summary | |
---|---|
URL |
createUrl(URL baseUrl,
Map<String,String> queryStringKvp)
Creates an URL with baseUrl and a query string defined by the kvp key/value
pair of parameters. |
int |
getTimeoutMillis()
Returns the request timeout in milliseconds, defaults to -1 meaning no timeout |
HTTPResponse |
issueGet(URL baseUrl,
Map<String,String> kvp)
Issues an HTTP request over the baseUrl with a query string defined by the kvp key/value pair of parameters. |
HTTPResponse |
issuePost(URL targetUrl,
HTTPProtocol.POSTCallBack callback)
|
boolean |
isTryGzip()
Returns whether gzip encoding is attempted when interacting with the HTTP server; default is false |
void |
setAuth(String username,
String password)
Sets the HTTP authentication realms (not required/used so far, but intended to be) |
void |
setTimeoutMillis(int milliseconds)
Sets the request timeout in milliseconds. |
void |
setTryGzip(boolean tryGzip)
Sets whether the server should be asked to return responses encoded in GZIP. |
Method Detail |
---|
void setTryGzip(boolean tryGzip)
tryGzip
- true
to ask the server to encode responses in GZIP.boolean isTryGzip()
false
true
if gzip is being attempted.void setAuth(String username, String password)
username
- password
- void setTimeoutMillis(int milliseconds)
milliseconds
- int getTimeoutMillis()
HTTPResponse issueGet(URL baseUrl, Map<String,String> kvp) throws IOException
baseUrl
with a query string defined by the kvp
key/value pair of parameters.
If the base url query is not empty and already contains a parameter named as one of the
parameters in kvp
, the original parameter value in the baseUrl query is overriden by
the one in the kvp
map. For this purpose, the parameter name matching comparison is
made case insensitively.
baseUrl
- the URL where to fetch the contents fromkvp
- the set of key/value pairs to create the actual URL query string, may be empty
IOException
- if a communication error of some sort occurscreateUrl(URL, Map)
HTTPResponse issuePost(URL targetUrl, HTTPProtocol.POSTCallBack callback) throws IOException
IOException
URL createUrl(URL baseUrl, Map<String,String> queryStringKvp) throws MalformedURLException
baseUrl
and a query string defined by the kvp
key/value
pair of parameters.
If the base url query is not empty and already contains a parameter named as one of the
parameters in kvp
, the original parameter value in the baseUrl query is overriden by
the one in the kvp
map. For this purpose, the parameter name matching comparison is
made case insensitively.
baseUrl
- the original URL to create the new one fromkvp
- the set of key/value pairs to create the actual URL query string, may be empty
baseUrl
and the query string from queryStringKvp
MalformedURLException
- if the resulting URL is not valid
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |