Class HttpConnectionManager

  • All Implemented Interfaces:
    ConnectionManager, ResumableConnectionManager

    public class HttpConnectionManager
    extends Object
    implements ResumableConnectionManager
    Connection manager implementation that support HTTP and HTTPS URI:s. It supports Basic and Digest authentication schemes. When HTTPS is used it provides support for validation of both server- and client-side certificates.
    Since:
    3.0
    Author:
    Nicklas
    Last modified
    $Date: 2017-10-13 13:40:38 +0200 (fr, 13 okt 2017) $
    • Field Detail

      • uri

        private final URI uri
      • responseFilter

        private Filter<org.apache.http.HttpResponse> responseFilter
      • timeout

        private int timeout
    • Method Detail

      • getMetadata

        public UriMetadata getMetadata()
                                throws IOException
        Description copied from interface: ConnectionManager
        Get metadata about the resource. If no metadata can be obtained the handler should still create an empty UriMetadata object.
        Specified by:
        getMetadata in interface ConnectionManager
        Returns:
        A metadata object
        Throws:
        IOException - If there is an error getting the metadata
      • setResponseFilter

        public void setResponseFilter​(Filter<org.apache.http.HttpResponse> filter)
        Set a filter that will inspect the response before an input stream is returned to the calling code. The filter must return true to allow the processing to proceed. A false value aborts the processing. The filter may also throw an exception.
        Since:
        3.12
      • setTimeout

        public void setTimeout​(int timeoutInSeconds)
        Set a timeout in seconds to allocate for the request to return (not including downloading of data).
        Parameters:
        timeoutInSeconds - Timeout in seconds
        Since:
        3.12
      • createCloseableHttpClient

        public org.apache.http.impl.client.CloseableHttpClient createCloseableHttpClient​(URI uri,
                                                                                         ConnectionParameters parameters)
                                                                                  throws IOException
        Get a HttpClient object that has been configured to access the given URI.
        Throws:
        IOException
      • createMetadata

        public UriMetadata createMetadata​(URI uri,
                                          org.apache.http.HttpResponse response)
        Read metadata from the given http response and put the information in a UriMetadata object. This method uses whatever information that is in the response headers:
        • Content-Length: The length of the resource
        • Last-Modified: The last modified date
        • Content-Type: The MIME type and character set