Class HttpUtil


  • public class HttpUtil
    extends Object
    Centralizing the initializing of an HttpRequest or HttpRequest.Builder against the different Silverpeas's HTTP requirements such as proxy configurations for example.
    Author:
    silveryocha
    • Method Detail

      • httpClient

        public static HttpClient httpClient()
        Centralizing the getting of HTTP client configured with proxy host and proxy port if any.
        Returns:
        a HttpClient instance.
      • httpClientTrustingAnySslContext

        public static HttpClient httpClientTrustingAnySslContext()
                                                          throws GeneralSecurityException
        Centralizing the getting of HTTP client configured with proxy host and proxy port if any and with the acceptance of any SSL certificate whatever its validity.
        Returns:
        a HttpClient instance.
        Throws:
        GeneralSecurityException
      • httpClient

        public static HttpClient httpClient​(SSLContext sslContext)
        Centralizing the getting of HTTP client configured with proxy host and proxy port if any and with the acceptance of optional given SSL context.
        Parameters:
        sslContext - an optional SSL context.
        Returns:
        a HttpClient instance.
      • toUrl

        public static HttpRequest.Builder toUrl​(String url)
        Centralizing the getting of HTTP request builder initialized with given URL.
        Parameters:
        url - the URL to request.
        Returns:
        a HttpRequest.Builder instance.
      • toUri

        public static HttpRequest.Builder toUri​(URI uri)
        Centralizing the getting of HTTP request builder initialized with given URI.
        Parameters:
        uri - the URI to request.
        Returns:
        a HttpRequest.Builder instance.