Package org.tailormap.api.geotools
Class ResponseTeeingHTTPClient
java.lang.Object
org.tailormap.api.geotools.ResponseTeeingHTTPClient
- All Implemented Interfaces:
org.geotools.http.HTTPClient
Wrapper for a GeoTools HTTPClient that allows access to the response headers and body after the
original response has been consumed and disposed of by other code. The response body for the
latest request is kept in memory, a consumer can be specified to get responses of earlier
requests. Response headers of an unwrapped HTTPClient can only be retrieved when the response
isn't disposed, this wrapper allows response headers to be cached for retrieval even after
disposal.
-
Nested Class Summary
-
Constructor Summary
ConstructorDescriptionResponseTeeingHTTPClient
(org.geotools.http.HTTPClient wrapped) Wrap a GeoTools HTTPClient allowing access to the latest response body after it has been consumed by handing the client to a GeoTools module.ResponseTeeingHTTPClient
(org.geotools.http.HTTPClient wrapped, BiConsumer<URL, ResponseTeeingHTTPClient.TeeHTTPResponseWrapper> requestConsumer, Set<String> responseHeadersToCache) Wrap a GeoTools HTTPClient allowing access to the all responses after they have been consumed by handing the client to a GeoTools module by passing a consumer for each request URL and wrapped response. -
Method Summary
Modifier and TypeMethodDescriptionorg.geotools.http.HTTPResponse
org.geotools.http.HTTPResponse
int
org.geotools.http.HTTPResponse
byte[]
int
getUser()
boolean
org.geotools.http.HTTPResponse
post
(URL url, InputStream inputStream, String s) void
setConnectTimeout
(int connectTimeout) void
setExtraParams
(Map<String, String> extraParams) void
setPassword
(String password) void
setReadTimeout
(int readTimeout) void
setTryGzip
(boolean tryGZIP) void
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.geotools.http.HTTPClient
post
-
Constructor Details
-
ResponseTeeingHTTPClient
public ResponseTeeingHTTPClient(org.geotools.http.HTTPClient wrapped) Wrap a GeoTools HTTPClient allowing access to the latest response body after it has been consumed by handing the client to a GeoTools module. Note that getting the response headers after the original response has been consumed will return null without explicitly calling the other constructor with the responseHeadersToCache parameter.- Parameters:
wrapped
- The GeoTools HTTPClient to wrap
-
ResponseTeeingHTTPClient
public ResponseTeeingHTTPClient(org.geotools.http.HTTPClient wrapped, BiConsumer<URL, ResponseTeeingHTTPClient.TeeHTTPResponseWrapper> requestConsumer, Set<String> responseHeadersToCache) Wrap a GeoTools HTTPClient allowing access to the all responses after they have been consumed by handing the client to a GeoTools module by passing a consumer for each request URL and wrapped response. The responseHeadersToCache parameter allows access to response headers after the original wrapped response has been disposed (only cached when getResponseStream() is requested).- Parameters:
wrapped
- The GeoTools HTTPClient to wraprequestConsumer
- Consumer for each request so not only the latest response can be accessed, may be nullresponseHeadersToCache
- Which response headers to cache, may be null
-
-
Method Details
-
get
- Specified by:
get
in interfaceorg.geotools.http.HTTPClient
- Throws:
IOException
-
post
public org.geotools.http.HTTPResponse post(URL url, InputStream inputStream, String s) throws IOException - Specified by:
post
in interfaceorg.geotools.http.HTTPClient
- Throws:
IOException
-
get
- Specified by:
get
in interfaceorg.geotools.http.HTTPClient
- Throws:
IOException
-
getLatestResponse
public org.geotools.http.HTTPResponse getLatestResponse() -
getLatestResponseCopy
public byte[] getLatestResponseCopy() -
getUser
- Specified by:
getUser
in interfaceorg.geotools.http.HTTPClient
-
setUser
- Specified by:
setUser
in interfaceorg.geotools.http.HTTPClient
-
getPassword
- Specified by:
getPassword
in interfaceorg.geotools.http.HTTPClient
-
setPassword
- Specified by:
setPassword
in interfaceorg.geotools.http.HTTPClient
-
getExtraParams
- Specified by:
getExtraParams
in interfaceorg.geotools.http.HTTPClient
-
setExtraParams
- Specified by:
setExtraParams
in interfaceorg.geotools.http.HTTPClient
-
getConnectTimeout
public int getConnectTimeout()- Specified by:
getConnectTimeout
in interfaceorg.geotools.http.HTTPClient
-
setConnectTimeout
public void setConnectTimeout(int connectTimeout) - Specified by:
setConnectTimeout
in interfaceorg.geotools.http.HTTPClient
-
getReadTimeout
public int getReadTimeout()- Specified by:
getReadTimeout
in interfaceorg.geotools.http.HTTPClient
-
setReadTimeout
public void setReadTimeout(int readTimeout) - Specified by:
setReadTimeout
in interfaceorg.geotools.http.HTTPClient
-
setTryGzip
public void setTryGzip(boolean tryGZIP) - Specified by:
setTryGzip
in interfaceorg.geotools.http.HTTPClient
-
isTryGzip
public boolean isTryGzip()- Specified by:
isTryGzip
in interfaceorg.geotools.http.HTTPClient
-