Class 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.
    • 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 wrap
        requestConsumer - Consumer for each request so not only the latest response can be accessed, may be null
        responseHeadersToCache - Which response headers to cache, may be null
    • Method Detail

      • get

        public org.geotools.http.HTTPResponse get​(URL url)
                                           throws IOException
        Specified by:
        get in interface org.geotools.http.HTTPClient
        Throws:
        IOException
      • getLatestResponse

        public org.geotools.http.HTTPResponse getLatestResponse()
      • getLatestResponseCopy

        public byte[] getLatestResponseCopy()
      • getUser

        public String getUser()
        Specified by:
        getUser in interface org.geotools.http.HTTPClient
      • setUser

        public void setUser​(String user)
        Specified by:
        setUser in interface org.geotools.http.HTTPClient
      • getPassword

        public String getPassword()
        Specified by:
        getPassword in interface org.geotools.http.HTTPClient
      • setPassword

        public void setPassword​(String password)
        Specified by:
        setPassword in interface org.geotools.http.HTTPClient
      • getConnectTimeout

        public int getConnectTimeout()
        Specified by:
        getConnectTimeout in interface org.geotools.http.HTTPClient
      • setConnectTimeout

        public void setConnectTimeout​(int connectTimeout)
        Specified by:
        setConnectTimeout in interface org.geotools.http.HTTPClient
      • getReadTimeout

        public int getReadTimeout()
        Specified by:
        getReadTimeout in interface org.geotools.http.HTTPClient
      • setReadTimeout

        public void setReadTimeout​(int readTimeout)
        Specified by:
        setReadTimeout in interface org.geotools.http.HTTPClient
      • setTryGzip

        public void setTryGzip​(boolean tryGZIP)
        Specified by:
        setTryGzip in interface org.geotools.http.HTTPClient
      • isTryGzip

        public boolean isTryGzip()
        Specified by:
        isTryGzip in interface org.geotools.http.HTTPClient