Class HttpUtil


  • public class HttpUtil
    extends Object
    Author:
    Pavel.Sher Date: 09.04.2009
    • Constructor Detail

      • HttpUtil

        public HttpUtil()
    • Method Detail

      • createHttpClient

        @NotNull
        public static org.apache.commons.httpclient.HttpClient createHttpClient​(int connectionTimeoutSeconds,
                                                                                @Nullable
                                                                                URL url,
                                                                                @Nullable
                                                                                org.apache.commons.httpclient.Credentials credentials)
        Creates new HTTP client with specified timeout and credentials set for basic authentication
        Parameters:
        connectionTimeoutSeconds - socket read & connection timeout (seconds)
        url - url to set auth scope
        credentials - credentials to set AuthScope
        Returns:
        new HTTP client instance
      • createHttpClient

        @NotNull
        public static org.apache.commons.httpclient.HttpClient createHttpClient​(int connectionTimeoutSeconds,
                                                                                @Nullable
                                                                                URL url,
                                                                                @Nullable
                                                                                org.apache.commons.httpclient.Credentials credentials,
                                                                                boolean isBasicAuth)
        Creates new HTTP client with specified timeout and credentials
        Parameters:
        connectionTimeoutSeconds - socket read & connection timeout (seconds)
        url - url to set auth scope
        credentials - credentials to set AuthScope
        isBasicAuth - true if basic authentication is used, false otherwise
        Returns:
        new HTTP client instance
      • createHttpClient

        @NotNull
        public static org.apache.commons.httpclient.HttpClient createHttpClient​(int connectionTimeoutSeconds)
        Creates new HTTP client with specified timeout and credentials set for basic authentication
        Parameters:
        connectionTimeoutSeconds - socket read & connection timeout (seconds)
        Returns:
        new HTTP client instance
      • createMultiThreadedHttpConnectionManager

        @NotNull
        public static org.apache.commons.httpclient.HttpConnectionManager createMultiThreadedHttpConnectionManager​(int connectionTimeoutSeconds)
        Creates new MultiThreadedHttpConnectionManager with specified timeouts
        Since:
        2019.2.1
      • createMultiThreadedHttpConnectionManager

        public static org.apache.commons.httpclient.HttpConnectionManager createMultiThreadedHttpConnectionManager​(int responseTimeoutSeconds,
                                                                                                                   int connectionTimeoutSeconds)
      • postMethod

        public static org.apache.commons.httpclient.methods.PostMethod postMethod​(@NotNull
                                                                                  org.apache.commons.httpclient.HttpClient client,
                                                                                  @NotNull
                                                                                  String url,
                                                                                  @Nullable
                                                                                  KeyStore trustStore,
                                                                                  boolean followRedirects)
                                                                           throws MalformedURLException
        Throws:
        MalformedURLException
      • configureProxy

        public static void configureProxy​(@NotNull
                                          org.apache.commons.httpclient.HttpClient client,
                                          @NotNull
                                          String proxyHost,
                                          int proxyPort,
                                          @Nullable
                                          SimpleCredentials proxyCredentials)
      • composeHttpErrorMessage

        public static String composeHttpErrorMessage​(org.apache.commons.httpclient.StatusLine status,
                                                     String errorMessagePrefix)
      • patchHttpConnectionParameters

        public static void patchHttpConnectionParameters​(@NotNull
                                                         org.apache.commons.httpclient.params.HttpConnectionManagerParams parametersToPatch)
        Patch http connection manager parameters with tc-specific values
        Parameters:
        parametersToPatch - HttpConnectionManagerParams
        Since:
        2019.2
      • getRedirectUrl

        @Nullable
        public static String getRedirectUrl​(org.apache.commons.httpclient.HttpMethodBase method)
        Checks if method response is a redirect and return redirect url if it is
        Since:
        2019.1.2