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
Nested Classes -
Constructor Summary
ConstructorsConstructorDescriptionResponseTeeingHTTPClient(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.HTTPResponseorg.geotools.http.HTTPResponseintorg.geotools.http.HTTPResponsebyte[]intgetUser()booleanorg.geotools.http.HTTPResponsepost(URL url, InputStream inputStream, String s) voidsetConnectTimeout(int connectTimeout) voidsetExtraParams(Map<String, String> extraParams) voidsetPassword(String password) voidsetReadTimeout(int readTimeout) voidsetTryGzip(boolean tryGZIP) voidMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods 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:
getin interfaceorg.geotools.http.HTTPClient- Throws:
IOException
-
post
public org.geotools.http.HTTPResponse post(URL url, InputStream inputStream, String s) throws IOException - Specified by:
postin interfaceorg.geotools.http.HTTPClient- Throws:
IOException
-
get
- Specified by:
getin interfaceorg.geotools.http.HTTPClient- Throws:
IOException
-
getLatestResponse
public org.geotools.http.HTTPResponse getLatestResponse() -
getLatestResponseCopy
public byte[] getLatestResponseCopy() -
getUser
- Specified by:
getUserin interfaceorg.geotools.http.HTTPClient
-
setUser
- Specified by:
setUserin interfaceorg.geotools.http.HTTPClient
-
getPassword
- Specified by:
getPasswordin interfaceorg.geotools.http.HTTPClient
-
setPassword
- Specified by:
setPasswordin interfaceorg.geotools.http.HTTPClient
-
getExtraParams
- Specified by:
getExtraParamsin interfaceorg.geotools.http.HTTPClient
-
setExtraParams
- Specified by:
setExtraParamsin interfaceorg.geotools.http.HTTPClient
-
getConnectTimeout
public int getConnectTimeout()- Specified by:
getConnectTimeoutin interfaceorg.geotools.http.HTTPClient
-
setConnectTimeout
public void setConnectTimeout(int connectTimeout) - Specified by:
setConnectTimeoutin interfaceorg.geotools.http.HTTPClient
-
getReadTimeout
public int getReadTimeout()- Specified by:
getReadTimeoutin interfaceorg.geotools.http.HTTPClient
-
setReadTimeout
public void setReadTimeout(int readTimeout) - Specified by:
setReadTimeoutin interfaceorg.geotools.http.HTTPClient
-
setTryGzip
public void setTryGzip(boolean tryGZIP) - Specified by:
setTryGzipin interfaceorg.geotools.http.HTTPClient
-
isTryGzip
public boolean isTryGzip()- Specified by:
isTryGzipin interfaceorg.geotools.http.HTTPClient
-