Class HttpHelper


  • public abstract class HttpHelper
    extends Object
    HTTP Helper functions
    • Field Detail

      • log

        protected static final org.apache.logging.log4j.Logger log
    • Constructor Detail

      • HttpHelper

        private HttpHelper()
    • Method Detail

      • httpClientPostBody

        public static final String httpClientPostBody​(String url)
                                               throws org.apache.commons.httpclient.HttpException,
                                                      UnsupportedEncodingException
        Send a HTTP POST request and return the body
        Parameters:
        url - url to call
        Returns:
        returned http body
        Throws:
        org.apache.commons.httpclient.HttpException - Http error
        UnsupportedEncodingException - Encoding error
      • httpClientPostBody

        public static final String httpClientPostBody​(String url,
                                                      ArrayList<org.apache.commons.httpclient.NameValuePair> list)
                                               throws org.apache.commons.httpclient.HttpException,
                                                      UnsupportedEncodingException
        Send a HTTP POST request with parameters and return the body
        Parameters:
        url - url to call
        list - parameters
        Returns:
        returned http body
        Throws:
        org.apache.commons.httpclient.HttpException - Http error
        UnsupportedEncodingException - Encoding error
      • httpClientPost

        public static final HttpResponse httpClientPost​(String url)
                                                 throws org.apache.commons.httpclient.HttpException,
                                                        UnsupportedEncodingException
        Send a HTTP POST request and return the HttpResponse object
        Parameters:
        url - url to call
        Returns:
        HttpResponse returned
        Throws:
        org.apache.commons.httpclient.HttpException - Http error
        UnsupportedEncodingException - Encoding error
      • httpClientPost

        public static final HttpResponse httpClientPost​(String url,
                                                        ArrayList<org.apache.commons.httpclient.NameValuePair> list,
                                                        String payload)
                                                 throws org.apache.commons.httpclient.HttpException,
                                                        UnsupportedEncodingException
        Send a HTTP POST request and return the HttpResponse object
        Parameters:
        url - url to call
        list - parameters
        payload - payload to add to the request
        Returns:
        HttpResponse returned
        Throws:
        org.apache.commons.httpclient.HttpException - Http error
        UnsupportedEncodingException - Encoding error
      • httpClientPut

        public static final HttpResponse httpClientPut​(String url,
                                                       ArrayList<org.apache.commons.httpclient.NameValuePair> list,
                                                       String payload)
                                                throws org.apache.commons.httpclient.HttpException,
                                                       UnsupportedEncodingException
        Send a HTTP PUT request and return the HttpResponse object
        Parameters:
        url - url to call
        list - parameters
        payload - payload to add to the request
        Returns:
        HttpResponse returned
        Throws:
        org.apache.commons.httpclient.HttpException - Http error
        UnsupportedEncodingException - Encoding error
      • httpClientGenericMethod

        public static final HttpResponse httpClientGenericMethod​(org.apache.commons.httpclient.methods.EntityEnclosingMethod method,
                                                                 ArrayList<org.apache.commons.httpclient.NameValuePair> list,
                                                                 String payload)
                                                          throws org.apache.commons.httpclient.HttpException,
                                                                 UnsupportedEncodingException
        Send a HTTP request with parameters and return the HttpResponse object
        Parameters:
        method - EntityEnclosingMethod
        list - list of params
        payload - payload to add to the request
        Returns:
        HttpResponse
        Throws:
        org.apache.commons.httpclient.HttpException - HttpException
        UnsupportedEncodingException - UnsupportedEncodingException
      • httpClientGenericMethod

        public static final HttpResponse httpClientGenericMethod​(org.apache.commons.httpclient.HttpClient client,
                                                                 org.apache.commons.httpclient.methods.EntityEnclosingMethod method,
                                                                 ArrayList<org.apache.commons.httpclient.NameValuePair> list,
                                                                 String payload)
                                                          throws org.apache.commons.httpclient.HttpException,
                                                                 UnsupportedEncodingException
        Send a HTTP request with parameters and return the HttpResponse object
        Parameters:
        client - HttpClient
        method - EntityEnclosingMethod
        list - list of params
        payload - payload to add to the request
        Returns:
        HttpResponse
        Throws:
        org.apache.commons.httpclient.HttpException - HttpException
        UnsupportedEncodingException - UnsupportedEncodingException
      • httpClientGet

        public static final HttpResponse httpClientGet​(String url)
                                                throws org.apache.commons.httpclient.HttpException
        Send a HTTP GET request and return the HttpResponse object
        Parameters:
        url - the url
        Returns:
        HttpResponse
        Throws:
        org.apache.commons.httpclient.HttpException - HttpException
      • httpClientGet

        public static final HttpResponse httpClientGet​(org.apache.commons.httpclient.HttpClient client,
                                                       org.apache.commons.httpclient.methods.GetMethod getMethod)
                                                throws org.apache.commons.httpclient.HttpException
        Send a HTTP GET request and return the HttpResponse object
        Parameters:
        client - HttpClient
        getMethod - GetMethod
        Returns:
        HttpResponse
        Throws:
        org.apache.commons.httpclient.HttpException - HttpException
      • httpClientHead

        public static final HttpResponse httpClientHead​(org.apache.commons.httpclient.HttpClient client,
                                                        org.apache.commons.httpclient.methods.HeadMethod headMethod)
                                                 throws org.apache.commons.httpclient.HttpException
        Send a HTTP HEAD request and return the HttpResponse object
        Parameters:
        client - HttpClient
        headMethod - HeadMethod
        Returns:
        HttpResponse
        Throws:
        org.apache.commons.httpclient.HttpException - HttpException
      • httpClientRead

        public static final HttpResponse httpClientRead​(org.apache.commons.httpclient.HttpClient client,
                                                        org.apache.commons.httpclient.HttpMethodBase method)
                                                 throws org.apache.commons.httpclient.HttpException
        Send a HTTP GET or HEAD request and return the HttpResponse object
        Parameters:
        client - HttpClient
        method - HttpMethodBase
        Returns:
        HttpResponse
        Throws:
        org.apache.commons.httpclient.HttpException - HttpException
      • download

        public static void download​(String url,
                                    String destinationPath)
                             throws IOException
        Download the content of a resource
        Parameters:
        url - the url of the resource
        destinationPath - the path where the resource will be downloaded
        Throws:
        IOException - Exception during the download
      • download

        public static InputStream download​(String url,
                                           Boolean isRangeRequest,
                                           Integer startRange,
                                           Integer endRange)
                                    throws IOException
        Download the content of a resource
        Parameters:
        url - the url
        isRangeRequest - indicates if is a range request
        startRange - the start of the bytes range
        endRange - the end of the bytes range
        Returns:
        an InputStream that represents the binary content
        Throws:
        IOException - Exception during the download
      • httpClientDelete

        public static final HttpResponse httpClientDelete​(String url)
                                                   throws org.apache.commons.httpclient.HttpException
        Send a HTTP DELETE request and return the HttpResponse object
        Parameters:
        url - url to call
        Returns:
        HttpResponse returned
        Throws:
        org.apache.commons.httpclient.HttpException - Http error