Package nl.b3p.tailormap.api.geotools
Class ResponseTeeingHTTPClient
- java.lang.Object
-
- nl.b3p.tailormap.api.geotools.ResponseTeeingHTTPClient
-
- All Implemented Interfaces:
org.geotools.http.HTTPClient
public class ResponseTeeingHTTPClient extends Object implements 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 Modifier and Type Class Description classResponseTeeingHTTPClient.TeeHTTPResponseWrapper
-
Constructor Summary
Constructors Constructor Description 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.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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description org.geotools.http.HTTPResponseget(URL url)org.geotools.http.HTTPResponseget(URL url, Map<String,String> headers)intgetConnectTimeout()org.geotools.http.HTTPResponsegetLatestResponse()byte[]getLatestResponseCopy()StringgetPassword()intgetReadTimeout()StringgetUser()booleanisTryGzip()org.geotools.http.HTTPResponsepost(URL url, InputStream inputStream, String s)voidsetConnectTimeout(int connectTimeout)voidsetPassword(String password)voidsetReadTimeout(int readTimeout)voidsetTryGzip(boolean tryGZIP)voidsetUser(String user)
-
-
-
Constructor Detail
-
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 Detail
-
get
public org.geotools.http.HTTPResponse get(URL url, Map<String,String> headers) throws IOException
- 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
public org.geotools.http.HTTPResponse get(URL url) throws IOException
- Specified by:
getin interfaceorg.geotools.http.HTTPClient- Throws:
IOException
-
getLatestResponse
public org.geotools.http.HTTPResponse getLatestResponse()
-
getLatestResponseCopy
public byte[] getLatestResponseCopy()
-
getUser
public String getUser()
- Specified by:
getUserin interfaceorg.geotools.http.HTTPClient
-
setUser
public void setUser(String user)
- Specified by:
setUserin interfaceorg.geotools.http.HTTPClient
-
getPassword
public String getPassword()
- Specified by:
getPasswordin interfaceorg.geotools.http.HTTPClient
-
setPassword
public void setPassword(String password)
- Specified by:
setPasswordin 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
-
-