Class DelegateHTTPClient
- All Implemented Interfaces:
HTTPClient
- Direct Known Subclasses:
LoggingHTTPClient
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionExecutes an HTTP GET request against the provided URL and returns the server response.Executes an HTTP GET request against the provided URL and returns the server response.intOptional query parameters.intgetUser()booleanpost(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.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) void
-
Field Details
-
delegate
-
-
Constructor Details
-
DelegateHTTPClient
-
-
Method Details
-
post
public 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 interfaceHTTPClient- 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
HTTPResponseencapsulating the response to the HTTP POST request - Throws:
IOException
-
post
public HTTPResponse post(URL url, InputStream postContent, String postContentType, Map<String, String> headers) throws IOExceptionDescription 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 interfaceHTTPClient- 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 benullheaders- a list of custom headers to add to the request.- Returns:
- the
HTTPResponseencapsulating the response to the HTTP POST request - Throws:
IOException
-
get
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 interfaceHTTPClient- Parameters:
url- the URL to retrieve- Returns:
- an
HTTPResponseencapsulating the response to the HTTP GET request - Throws:
IOException
-
get
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 interfaceHTTPClient- Parameters:
url- the URL to retrieveheaders- a list of custom headers to add to the request.- Returns:
- an
HTTPResponseencapsulating the response to the HTTP GET request - Throws:
IOException
-
getUser
- Specified by:
getUserin interfaceHTTPClient- Returns:
- the HTTP BASIC Authentication user name, or
nullif not set
-
setUser
- Specified by:
setUserin interfaceHTTPClient- Parameters:
user- the HTTP BASIC Authentication user name
-
getPassword
- Specified by:
getPasswordin interfaceHTTPClient- Returns:
- the HTTP BASIC Authentication password, or
nullif not set
-
setPassword
- Specified by:
setPasswordin interfaceHTTPClient- Parameters:
password- the HTTP BASIC Authentication password
-
getExtraParams
Description copied from interface:HTTPClientOptional query parameters.- Specified by:
getExtraParamsin interfaceHTTPClient- Returns:
- querystring ExtraParams, or
emptyMap()if not set
-
setExtraParams
- Specified by:
setExtraParamsin interfaceHTTPClient- Parameters:
extraParams- the optional querystring ExtraParams to be appended to finalURL
-
getConnectTimeout
public int getConnectTimeout()- Specified by:
getConnectTimeoutin interfaceHTTPClient- Returns:
- the tcp/ip connect timeout in seconds
-
setConnectTimeout
public void setConnectTimeout(int connectTimeout) - Specified by:
setConnectTimeoutin interfaceHTTPClient- Parameters:
connectTimeout- tcp/ip connect timeout in seconds
-
getReadTimeout
public int getReadTimeout()- Specified by:
getReadTimeoutin interfaceHTTPClient- Returns:
- the socket read timeout in seconds
-
setReadTimeout
public void setReadTimeout(int readTimeout) - Specified by:
setReadTimeoutin interfaceHTTPClient- Parameters:
readTimeout- socket read timeout in seconds
-
setTryGzip
public void setTryGzip(boolean tryGZIP) - Specified by:
setTryGzipin interfaceHTTPClient
-
isTryGzip
public boolean isTryGzip()- Specified by:
isTryGzipin interfaceHTTPClient- Returns:
- whether gzip content encoding will be attempted; defaults to
false
-