Class HttpClientManager


  • public class HttpClientManager
    extends Object
    Convenience routines that wrap HTTPSession.
    • Constructor Detail

      • HttpClientManager

        public HttpClientManager()
    • Method Detail

      • init

        public static void init​(org.apache.http.client.CredentialsProvider provider,
                                String userAgent)
        initialize the HttpClient layer.
        Parameters:
        provider - CredentialsProvider.
        userAgent - Content of User-Agent header, may be null
      • getContentAsString

        public static String getContentAsString​(String urlencoded)
                                         throws IOException
        Get the content from a url. For large returns, its better to use getResponseAsStream.
        Parameters:
        urlencoded - url as a String
        Returns:
        contents of url as a String
        Throws:
        IOException - on error
      • getContentAsString

        @Deprecated
        public static String getContentAsString​(HTTPSession session,
                                                String urlencoded)
                                         throws IOException
        Deprecated.
        Get the content from a url. For large returns, its better to use getResponseAsStream.
        Parameters:
        session - use this session, if null, create a new one
        urlencoded - url as a String
        Returns:
        contents of url as a String
        Throws:
        IOException - on error
      • putContent

        public static int putContent​(String urlencoded,
                                     String content)
                              throws IOException
        Put content to a url, using HTTP PUT. Handles one level of 302 redirection.
        Parameters:
        urlencoded - url as a String
        content - PUT this content at the given url.
        Returns:
        the HTTP status return code
        Throws:
        IOException - on error
      • appendUrlContentsToFile

        public static long appendUrlContentsToFile​(String urlencoded,
                                                   File file,
                                                   long start,
                                                   long end)
                                            throws IOException
        Throws:
        IOException