public class MultithreadedHttpClient extends Object implements HTTPClient
HTTPClient
backed by a multithreaded connection
manager that allows to reuse connections to the backing server and to limit the max number of concurrent connections
.
Java System properties http.proxyHost
, http.proxyPort
, http.proxyUser
,
and http.proxyPassword
are respected.
AbstractOpenWebService.setHttpClient(HTTPClient)
Constructor and Description |
---|
MultithreadedHttpClient() |
Modifier and Type | Method and Description |
---|---|
HttpClient |
createHttpClient() |
HTTPResponse |
get(URL url)
Executes an HTTP GET request against the provided URL and returns the server response.
|
int |
getConnectTimeout() |
int |
getMaxConnections() |
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 of
postContent as the POST method body and setting the Content-Type request header to postContentType if given, and returns the server response. |
void |
setConnectTimeout(int connectTimeout) |
void |
setMaxConnections(int maxConnections) |
void |
setPassword(String password) |
void |
setReadTimeout(int readTimeout) |
void |
setTryGzip(boolean tryGZIP) |
void |
setUser(String user) |
public HttpClient createHttpClient()
public HTTPResponse post(URL url, InputStream postContent, String postContentType) throws IOException
HTTPClient
postContent
as the POST method body and setting the Content-Type request header to postContentType
if given, and returns the server response.
If an HTTP authentication user
and password
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.
post
in interface HTTPClient
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 be
null
HTTPResponse
encapsulating the response to the HTTP POST requestIOException
public HTTPResponse get(URL url) throws IOException
HTTPClient
If an HTTP authentication user
and password
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.
get
in interface HTTPClient
url
- the URL to retrieveHTTPResponse
encapsulating the response to the HTTP GET requestIOException
public String getUser()
getUser
in interface HTTPClient
null
if not setpublic void setUser(String user)
setUser
in interface HTTPClient
user
- the HTTP BASIC Authentication user namepublic String getPassword()
getPassword
in interface HTTPClient
null
if not setpublic void setPassword(String password)
setPassword
in interface HTTPClient
password
- the HTTP BASIC Authentication passwordpublic int getConnectTimeout()
getConnectTimeout
in interface HTTPClient
public void setConnectTimeout(int connectTimeout)
setConnectTimeout
in interface HTTPClient
connectTimeout
- tcp/ip connect timeout in secondspublic int getReadTimeout()
getReadTimeout
in interface HTTPClient
public void setReadTimeout(int readTimeout)
setReadTimeout
in interface HTTPClient
readTimeout
- socket read timeout in secondspublic int getMaxConnections()
public void setMaxConnections(int maxConnections)
public void setTryGzip(boolean tryGZIP)
setTryGzip
in interface HTTPClient
tryGZIP
- HTTPClient.setTryGzip(boolean)
public boolean isTryGzip()
isTryGzip
in interface HTTPClient
HTTPClient.isTryGzip()
Copyright © 1996–2019 Geotools. All rights reserved.