Class Unirest


  • public class Unirest
    extends Object
    • Constructor Detail

      • Unirest

        public Unirest()
    • Method Detail

      • setHttpClient

        public static void setHttpClient​(org.apache.http.client.HttpClient httpClient)
        Set the HttpClient implementation to use for every synchronous request
      • setAsyncHttpClient

        public static void setAsyncHttpClient​(org.apache.http.impl.nio.client.CloseableHttpAsyncClient asyncHttpClient)
        Set the asynchronous AbstractHttpAsyncClient implementation to use for every asynchronous request
      • setProxy

        public static void setProxy​(org.apache.http.HttpHost proxy)
        Set a proxy
      • setTimeouts

        public static void setTimeouts​(long connectionTimeout,
                                       long socketTimeout)
        Set the connection timeout and socket timeout
        Parameters:
        connectionTimeout - The timeout until a connection with the server is established (in milliseconds). Default is 10000. Set to zero to disable the timeout.
        socketTimeout - The timeout to receive data (in milliseconds). Default is 60000. Set to zero to disable the timeout.
      • setConcurrency

        public static void setConcurrency​(int maxTotal,
                                          int maxPerRoute)
        Set the concurrency levels
        Parameters:
        maxTotal - Defines the overall connection limit for a connection pool. Default is 200.
        maxPerRoute - Defines a connection limit per one HTTP route (this can be considered a per target host limit). Default is 20.
      • clearDefaultHeaders

        public static void clearDefaultHeaders()
        Clear default headers
      • setDefaultHeader

        public static void setDefaultHeader​(String name,
                                            String value)
        Set default header
      • shutdown

        public static void shutdown()
                             throws IOException
        Close the asynchronous client and its event loop. Use this method to close all the threads and allow an application to exit.
        Throws:
        IOException