Class MultithreadedHttpClient

    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void close()  
      HTTPResponse get​(URL url)
      Executes an HTTP GET request against the provided URL and returns the server response.
      HTTPResponse get​(URL url, Map<String,​String> headers)
      Executes an HTTP GET request against the provided URL and returns the server response.
      int getConnectTimeout()  
      int getMaxConnections()
      Max connections kept in the pool
      int getReadTimeout()  
      MultithreadedHttpClient.HttpMethodResponse post​(URL url, InputStream postContent, String postContentType)
      Executes an HTTP POST request against the provided URL, sending the contents of postContent as the POST method body and setting the Content-Type request header to postContentType if given, and returns the server response.
      MultithreadedHttpClient.HttpMethodResponse post​(URL url, InputStream postContent, String postContentType, Map<String,​String> headers)
      Executes an HTTP POST request against the provided URL, sending the contents of postContent as the POST method body and setting the Content-Type request header to postContentType if given, and returns the server response.
      void setConnectTimeout​(int connectTimeout)  
      void setMaxConnections​(int maxConnections)
      Sets max connections kept in the pool
      void setPassword​(String password)  
      void setReadTimeout​(int readTimeout)  
      void setUser​(String user)  
      • Methods inherited from class Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • MultithreadedHttpClient

        public MultithreadedHttpClient()
    • Method Detail

      • post

        public MultithreadedHttpClient.HttpMethodResponse post​(URL url,
                                                               InputStream postContent,
                                                               String postContentType)
                                                        throws IOException
        Description copied from interface: HTTPClient
        Executes an HTTP POST request against the provided URL, sending the contents of postContent as the POST method body and setting the Content-Type request header to postContentType if given, and returns the server response.

        If an HTTP authentication user and password is set, the appropriate authentication HTTP header will be sent with the request.

        If a connection timeout is set, the http connection will be set to respect that timeout.

        If a read timeout is set, the http connection will be set to respect it.

        Specified by:
        post in interface HTTPClient
        Specified by:
        post in class AbstractHttpClient
        Parameters:
        url - the URL against which to execute the POST request
        postContent - an input stream with the contents of the POST body
        postContentType - the MIME type of the contents sent as the request POST body, can be null
        Returns:
        the HTTPResponse encapsulating the response to the HTTP POST request
        Throws:
        IOException
      • post

        public MultithreadedHttpClient.HttpMethodResponse post​(URL url,
                                                               InputStream postContent,
                                                               String postContentType,
                                                               Map<String,​String> headers)
                                                        throws IOException
        Description copied from interface: HTTPClient
        Executes an HTTP POST request against the provided URL, sending the contents of postContent as the POST method body and setting the Content-Type request header to postContentType if given, and returns the server response.

        If an HTTP authentication user and password is set, the appropriate authentication HTTP header will be sent with the request.

        If a connection timeout is set, the http connection will be set to respect that timeout.

        If a read timeout is set, the http connection will be set to respect it.

        header parameter contains additional headers to add to the request.

        Specified by:
        post in interface HTTPClient
        Parameters:
        url - the URL against which to execute the POST request
        postContent - an input stream with the contents of the POST body
        postContentType - the MIME type of the contents sent as the request POST body, can be null
        headers - a list of custom headers to add to the request.
        Returns:
        the HTTPResponse encapsulating the response to the HTTP POST request
        Throws:
        IOException
      • get

        public HTTPResponse get​(URL url)
                         throws IOException
        Description copied from interface: HTTPClient
        Executes an HTTP GET request against the provided URL and returns the server response.

        If an HTTP authentication user and password is set, the appropriate authentication HTTP header will be sent with the request.

        If a connection timeout is set, the http connection will be set to respect that timeout.

        If a read timeout is set, the http connection will be set to respect it.

        Specified by:
        get in interface HTTPClient
        Parameters:
        url - the URL to retrieve
        Returns:
        an HTTPResponse encapsulating the response to the HTTP GET request
        Throws:
        IOException
      • get

        public HTTPResponse get​(URL url,
                                Map<String,​String> headers)
                         throws IOException
        Description copied from interface: HTTPClient
        Executes an HTTP GET request against the provided URL and returns the server response.

        If an HTTP authentication user and password is set, the appropriate authentication HTTP header will be sent with the request.

        If a connection timeout is set, the http connection will be set to respect that timeout.

        If a read timeout is set, the http connection will be set to respect it.

        header parameter contains additional headers to add to the request.

        Specified by:
        get in interface HTTPClient
        Parameters:
        url - the URL to retrieve
        headers - a list of custom headers to add to the request.
        Returns:
        an HTTPResponse encapsulating the response to the HTTP GET request
        Throws:
        IOException
      • close

        public void close()
        Specified by:
        close in interface AutoCloseable
        Specified by:
        close in interface Closeable