Class DelegateHTTPClient
- Object
- 
- DelegateHTTPClient
 
- 
- All Implemented Interfaces:
- HTTPClient
 - Direct Known Subclasses:
- LoggingHTTPClient
 
 public class DelegateHTTPClient extends Object implements HTTPClient 
- 
- 
Field SummaryFields Modifier and Type Field Description protected HTTPClientdelegate
 - 
Constructor SummaryConstructors Constructor Description DelegateHTTPClient(HTTPClient delegate)
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description HTTPResponseget(URL url)Executes an HTTP GET request against the provided URL and returns the server response.HTTPResponseget(URL url, Map<String,String> headers)Executes an HTTP GET request against the provided URL and returns the server response.intgetConnectTimeout()Map<String,String>getExtraParams()Optional query parameters.StringgetPassword()intgetReadTimeout()StringgetUser()booleanisTryGzip()HTTPResponsepost(URL url, InputStream postContent, String postContentType)Executes an HTTP POST request against the provided URL, sending the contents ofpostContentas the POST method body and setting the Content-Type request header topostContentTypeif given, and returns the server response.HTTPResponsepost(URL url, InputStream postContent, String postContentType, Map<String,String> headers)Executes an HTTP POST request against the provided URL, sending the contents ofpostContentas the POST method body and setting the Content-Type request header topostContentTypeif given, and returns the server response.voidsetConnectTimeout(int connectTimeout)voidsetExtraParams(Map<String,String> extraParams)voidsetPassword(String password)voidsetReadTimeout(int readTimeout)voidsetTryGzip(boolean tryGZIP)voidsetUser(String user)
 
- 
- 
- 
Field Detail- 
delegateprotected HTTPClient delegate 
 
- 
 - 
Constructor Detail- 
DelegateHTTPClientpublic DelegateHTTPClient(HTTPClient delegate) 
 
- 
 - 
Method Detail- 
postpublic HTTPResponse post(URL url, InputStream postContent, String postContentType) throws IOException Description copied from interface:HTTPClientExecutes an HTTP POST request against the provided URL, sending the contents ofpostContentas the POST method body and setting the Content-Type request header topostContentTypeif given, and returns the server response.If an HTTP authentication userandpasswordis set, the appropriate authentication HTTP header will be sent with the request.If a connection timeoutis set, the http connection will be set to respect that timeout.If a read timeoutis set, the http connection will be set to respect it.- Specified by:
- postin interface- HTTPClient
- Parameters:
- url- the URL against which to execute the POST request
- postContent- an input stream with the contents of the POST body
- postContentType- the MIME type of the contents sent as the request POST body, can be- null
- Returns:
- the HTTPResponseencapsulating the response to the HTTP POST request
- Throws:
- IOException
 
 - 
postpublic HTTPResponse post(URL url, InputStream postContent, String postContentType, Map<String,String> headers) throws IOException Description copied from interface:HTTPClientExecutes an HTTP POST request against the provided URL, sending the contents ofpostContentas the POST method body and setting the Content-Type request header topostContentTypeif given, and returns the server response.If an HTTP authentication userandpasswordis set, the appropriate authentication HTTP header will be sent with the request.If a connection timeoutis set, the http connection will be set to respect that timeout.If a read timeoutis set, the http connection will be set to respect it.header parameter contains additional headers to add to the request. - Specified by:
- postin interface- HTTPClient
- Parameters:
- url- the URL against which to execute the POST request
- postContent- an input stream with the contents of the POST body
- postContentType- the MIME type of the contents sent as the request POST body, can be- null
- headers- a list of custom headers to add to the request.
- Returns:
- the HTTPResponseencapsulating the response to the HTTP POST request
- Throws:
- IOException
 
 - 
getpublic HTTPResponse get(URL url) throws IOException Description copied from interface:HTTPClientExecutes an HTTP GET request against the provided URL and returns the server response.If an HTTP authentication userandpasswordis set, the appropriate authentication HTTP header will be sent with the request.If a connection timeoutis set, the http connection will be set to respect that timeout.If a read timeoutis set, the http connection will be set to respect it.- Specified by:
- getin interface- HTTPClient
- Parameters:
- url- the URL to retrieve
- Returns:
- an HTTPResponseencapsulating the response to the HTTP GET request
- Throws:
- IOException
 
 - 
getpublic HTTPResponse get(URL url, Map<String,String> headers) throws IOException Description copied from interface:HTTPClientExecutes an HTTP GET request against the provided URL and returns the server response.If an HTTP authentication userandpasswordis set, the appropriate authentication HTTP header will be sent with the request.If a connection timeoutis set, the http connection will be set to respect that timeout.If a read timeoutis set, the http connection will be set to respect it.header parameter contains additional headers to add to the request. - Specified by:
- getin interface- HTTPClient
- Parameters:
- url- the URL to retrieve
- headers- a list of custom headers to add to the request.
- Returns:
- an HTTPResponseencapsulating the response to the HTTP GET request
- Throws:
- IOException
 
 - 
getUserpublic String getUser() - Specified by:
- getUserin interface- HTTPClient
- Returns:
- the HTTP BASIC Authentication user name, or nullif not set
 
 - 
setUserpublic void setUser(String user) - Specified by:
- setUserin interface- HTTPClient
- Parameters:
- user- the HTTP BASIC Authentication user name
 
 - 
getPasswordpublic String getPassword() - Specified by:
- getPasswordin interface- HTTPClient
- Returns:
- the HTTP BASIC Authentication password, or nullif not set
 
 - 
setPasswordpublic void setPassword(String password) - Specified by:
- setPasswordin interface- HTTPClient
- Parameters:
- password- the HTTP BASIC Authentication password
 
 - 
getExtraParamspublic Map<String,String> getExtraParams() Description copied from interface:HTTPClientOptional query parameters.- Specified by:
- getExtraParamsin interface- HTTPClient
- Returns:
- querystring ExtraParams, or emptyMap()if not set
 
 - 
setExtraParamspublic void setExtraParams(Map<String,String> extraParams) - Specified by:
- setExtraParamsin interface- HTTPClient
- Parameters:
- extraParams- the optional querystring ExtraParams to be appended to finalURL
 
 - 
getConnectTimeoutpublic int getConnectTimeout() - Specified by:
- getConnectTimeoutin interface- HTTPClient
- Returns:
- the tcp/ip connect timeout in seconds
 
 - 
setConnectTimeoutpublic void setConnectTimeout(int connectTimeout) - Specified by:
- setConnectTimeoutin interface- HTTPClient
- Parameters:
- connectTimeout- tcp/ip connect timeout in seconds
 
 - 
getReadTimeoutpublic int getReadTimeout() - Specified by:
- getReadTimeoutin interface- HTTPClient
- Returns:
- the socket read timeout in seconds
 
 - 
setReadTimeoutpublic void setReadTimeout(int readTimeout) - Specified by:
- setReadTimeoutin interface- HTTPClient
- Parameters:
- readTimeout- socket read timeout in seconds
 
 - 
setTryGzippublic void setTryGzip(boolean tryGZIP) - Specified by:
- setTryGzipin interface- HTTPClient
 
 - 
isTryGzippublic boolean isTryGzip() - Specified by:
- isTryGzipin interface- HTTPClient
- Returns:
- whether gzip content encoding will be attempted; defaults to false
 
 
- 
 
-