Class AbstractHttpRequest

    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      void execute()
      Executes this HTTP request and preserves the response stream and HTTP response code for processing.
      protected abstract java.net.HttpURLConnection getConnection()
      The method class will create the appropriate connection with an endpoint, parameters, etc.
      protected static java.net.HttpURLConnection getProxiedConnection​(java.lang.String url)
      Creates an HTTP connection.
      long getResponseAsFile​(java.io.File f)
      Write the last response to a file.
      java.lang.String getResponseBody()
      Returns the last response stream as a string.
      java.lang.Integer getResponseCode()
      Returns the last HTTP response code.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • DEFAULT_ENCODING

        public static final java.lang.String DEFAULT_ENCODING
        See Also:
        Constant Field Values
      • USER_AGENT

        public static final java.lang.String USER_AGENT
      • url

        protected java.lang.String url
      • lastHttpStatusCode

        protected java.lang.Integer lastHttpStatusCode
      • lastResponseStream

        protected java.io.InputStream lastResponseStream
    • Constructor Detail

      • AbstractHttpRequest

        public AbstractHttpRequest()
    • Method Detail

      • getProxiedConnection

        protected static java.net.HttpURLConnection getProxiedConnection​(java.lang.String url)
                                                                  throws java.net.MalformedURLException,
                                                                         java.io.IOException
        Creates an HTTP connection. Optionally checks for proxy parameters and creates a proxied connection using the system properties: "hellosign.proxy.url" - the URL of the HTTP proxy "hellosign.proxy.port" - the port of the HTTP proxy
        Parameters:
        url - String URL to connect to
        Returns:
        HttpUrlConnection the (proxied) connection to the URL
        Throws:
        java.net.MalformedURLException - thrown if the URL is invalid
        java.io.IOException - thrown if IO cannot be established with the URL
      • execute

        public void execute()
                     throws HelloSignException
        Executes this HTTP request and preserves the response stream and HTTP response code for processing.
        Throws:
        HelloSignException - Thrown if there is an error while making the HTTP request to the HelloSign API.
      • getResponseCode

        public java.lang.Integer getResponseCode()
        Returns the last HTTP response code.
        Returns:
        Integer response code
      • getResponseBody

        public java.lang.String getResponseBody()
        Returns the last response stream as a string.
        Returns:
        String
      • getConnection

        protected abstract java.net.HttpURLConnection getConnection()
                                                             throws HelloSignException
        The method class will create the appropriate connection with an endpoint, parameters, etc.
        Returns:
        HttpURLConnection
        Throws:
        HelloSignException - Thrown if a connection cannot be created
      • getResponseAsFile

        public long getResponseAsFile​(java.io.File f)
                               throws HelloSignException
        Write the last response to a file.
        Parameters:
        f - File
        Returns:
        long bytes written
        Throws:
        HelloSignException - Thrown if an exception occurs during the copy of the response stream to the given file.