Interface HTTPClient
-
- All Known Implementing Classes:
AbstractHttpClient
,DelegateHTTPClient
,LoggingHTTPClient
,MultithreadedHttpClient
,SimpleHttpClient
public interface HTTPClient
Defines the inteface by which anAbstractOpenWebService
executes HTTP requests.- Author:
- groldan
- See Also:
HTTPResponse
,SimpleHttpClient
,AbstractOpenWebService#setHttpClient(HTTPClient)
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description HTTPResponse
get(URL url)
Executes an HTTP GET request against the provided URL and returns the server response.default HTTPResponse
get(URL url, Map<String,String> headers)
Executes an HTTP GET request against the provided URL and returns the server response.int
getConnectTimeout()
Map<String,String>
getExtraParams()
Optional query parameters.String
getPassword()
int
getReadTimeout()
String
getUser()
boolean
isTryGzip()
HTTPResponse
post(URL url, InputStream postContent, String postContentType)
Executes an HTTP POST request against the provided URL, sending the contents ofpostContent
as the POST method body and setting the Content-Type request header topostContentType
if given, and returns the server response.default HTTPResponse
post(URL url, InputStream postContent, String postContentType, Map<String,String> headers)
Executes an HTTP POST request against the provided URL, sending the contents ofpostContent
as the POST method body and setting the Content-Type request header topostContentType
if given, and returns the server response.void
setConnectTimeout(int connectTimeout)
void
setExtraParams(Map<String,String> extraParams)
void
setPassword(String password)
void
setReadTimeout(int readTimeout)
void
setTryGzip(boolean tryGZIP)
void
setUser(String user)
-
-
-
Method Detail
-
post
HTTPResponse post(URL url, InputStream postContent, String postContentType) throws IOException
Executes an HTTP POST request against the provided URL, sending the contents ofpostContent
as the POST method body and setting the Content-Type request header topostContentType
if given, and returns the server response.If an HTTP authentication
user
andpassword
is set, the appropriate authentication HTTP header will be sent with the request.If a
connection timeout
is set, the http connection will be set to respect that timeout.If a
read timeout
is set, the http connection will be set to respect it.- Parameters:
url
- the URL against which to execute the POST requestpostContent
- an input stream with the contents of the POST bodypostContentType
- the MIME type of the contents sent as the request POST body, can benull
- Returns:
- the
HTTPResponse
encapsulating the response to the HTTP POST request - Throws:
IOException
-
post
default HTTPResponse post(URL url, InputStream postContent, String postContentType, Map<String,String> headers) throws IOException
Executes an HTTP POST request against the provided URL, sending the contents ofpostContent
as the POST method body and setting the Content-Type request header topostContentType
if given, and returns the server response.If an HTTP authentication
user
andpassword
is set, the appropriate authentication HTTP header will be sent with the request.If a
connection timeout
is set, the http connection will be set to respect that timeout.If a
read timeout
is set, the http connection will be set to respect it.header parameter contains additional headers to add to the request.
- Parameters:
url
- the URL against which to execute the POST requestpostContent
- an input stream with the contents of the POST bodypostContentType
- the MIME type of the contents sent as the request POST body, can benull
headers
- a list of custom headers to add to the request.- Returns:
- the
HTTPResponse
encapsulating the response to the HTTP POST request - Throws:
IOException
-
get
HTTPResponse get(URL url) throws IOException
Executes an HTTP GET request against the provided URL and returns the server response.If an HTTP authentication
user
andpassword
is set, the appropriate authentication HTTP header will be sent with the request.If a
connection timeout
is set, the http connection will be set to respect that timeout.If a
read timeout
is set, the http connection will be set to respect it.- Parameters:
url
- the URL to retrieve- Returns:
- an
HTTPResponse
encapsulating the response to the HTTP GET request - Throws:
IOException
-
get
default HTTPResponse get(URL url, Map<String,String> headers) throws IOException
Executes an HTTP GET request against the provided URL and returns the server response.If an HTTP authentication
user
andpassword
is set, the appropriate authentication HTTP header will be sent with the request.If a
connection timeout
is set, the http connection will be set to respect that timeout.If a
read timeout
is set, the http connection will be set to respect it.header parameter contains additional headers to add to the request.
- Parameters:
url
- the URL to retrieveheaders
- a list of custom headers to add to the request.- Returns:
- an
HTTPResponse
encapsulating the response to the HTTP GET request - Throws:
IOException
-
getUser
String getUser()
- Returns:
- the HTTP BASIC Authentication user name, or
null
if not set
-
setUser
void setUser(String user)
- Parameters:
user
- the HTTP BASIC Authentication user name
-
getPassword
String getPassword()
- Returns:
- the HTTP BASIC Authentication password, or
null
if not set
-
setPassword
void setPassword(String password)
- Parameters:
password
- the HTTP BASIC Authentication password
-
getExtraParams
Map<String,String> getExtraParams()
Optional query parameters.- Returns:
- querystring ExtraParams, or
emptyMap()
if not set
-
setExtraParams
void setExtraParams(Map<String,String> extraParams)
- Parameters:
extraParams
- the optional querystring ExtraParams to be appended to finalURL
-
getConnectTimeout
int getConnectTimeout()
- Returns:
- the tcp/ip connect timeout in seconds
-
setConnectTimeout
void setConnectTimeout(int connectTimeout)
- Parameters:
connectTimeout
- tcp/ip connect timeout in seconds
-
getReadTimeout
int getReadTimeout()
- Returns:
- the socket read timeout in seconds
-
setReadTimeout
void setReadTimeout(int readTimeout)
- Parameters:
readTimeout
- socket read timeout in seconds
-
setTryGzip
void setTryGzip(boolean tryGZIP)
- Parameters:
tryGZIP
-
-
isTryGzip
boolean isTryGzip()
- Returns:
- whether gzip content encoding will be attempted; defaults to
false
-
-