Class Request

    • Constructor Detail

      • Request

        public Request​(String url,
                       int connectionTimeout,
                       int readTimeout,
                       Proxy proxy,
                       String proxyUsername,
                       String proxyPassword)
        The Constructor takes the url as a String, a proxy as a Proxy, and proxy credentials as a String.
        Parameters:
        url - The url parameter does not need the query string parameters if they are going to be supplied via calls to addQueryParameter(String, String). You can, however, supply the query parameters in the URL if you wish.
        connectionTimeout - A specified timeout value, in milliseconds, to establish communications link to the resource by URLConnection.
        readTimeout - A specified timeout, in milliseconds, for reading data from an established connection to the resource by URLConnection.
        proxy - The Connection's Proxy value
        proxyUsername - The Proxy username
        proxyPassword - The Proxy password
    • Method Detail

      • addQueryParameter

        public Request addQueryParameter​(String name,
                                         String value)
        Adds a Query Parameter to a list. The list is converted to a String and appended to the URL when the Request is submitted.
        Parameters:
        name - The Query Parameter's name
        value - The Query Parameter's value
        Returns:
        this Request, to support chained method calls
      • removeQueryParameter

        public Request removeQueryParameter​(String name)
        Removes the specified Query Parameter.
        Parameters:
        name - The name of the Query Parameter to remove
        Returns:
        this Request, to support chained method calls
      • getResource

        public cc.protea.util.http.Response getResource()
                                                 throws IOException
        Issues a GET to the server.
        Returns:
        The Response from the server
        Throws:
        IOException - a IOException
      • getBinaryResource

        public cc.protea.util.http.BinaryResponse getBinaryResource()
                                                             throws IOException
        Issues a GET to the server.
        Returns:
        The Response from the server
        Throws:
        IOException - a IOException
      • putResource

        public cc.protea.util.http.Response putResource()
                                                 throws IOException
        Issues a PUT to the server.
        Returns:
        The Response from the server
        Throws:
        IOException - a IOException
      • optionsResource

        public cc.protea.util.http.Response optionsResource()
                                                     throws IOException
        Throws:
        IOException
      • postResource

        public cc.protea.util.http.Response postResource()
                                                  throws IOException
        Issues a POST to the server.
        Returns:
        The Response from the server
        Throws:
        IOException - a IOException
      • deleteResource

        public cc.protea.util.http.Response deleteResource()
                                                    throws IOException
        Issues a DELETE to the server.
        Returns:
        The Response from the server
        Throws:
        IOException - a IOException
      • readResponse

        protected cc.protea.util.http.Response readResponse()
                                                     throws IOException
        A private method that handles reading the Responses from the server.
        Returns:
        a Response from the server.
        Throws:
        IOException - a IOException
      • buildHeaders

        protected void buildHeaders()
        A private method that loops through the headers Map, putting them on the Request or Response object.