Class HTTPJavaImpl

    • Method Detail

      • setPostHeaders

        protected void setPostHeaders​(URLConnection conn)
                               throws IOException
        Set request headers in preparation to opening a connection.
        Parameters:
        conn - URLConnection to set headers on
        Throws:
        IOException - if an I/O exception occurs
      • sendPostData

        protected String sendPostData​(URLConnection connection)
                               throws IOException
        Send POST data from Entry to the open connection. This also handles sending data for PUT requests
        Parameters:
        connection - URLConnection where POST data should be sent
        Returns:
        a String show what was posted. Will not contain actual file upload content
        Throws:
        IOException - if an I/O exception occurs
      • setupConnection

        protected HttpURLConnection setupConnection​(URL u,
                                                    String method,
                                                    HTTPSampleResult res)
                                             throws IOException
        Returns an HttpURLConnection fully ready to attempt connection. This means it sets the request method (GET or POST), headers, cookies, and authorization for the URL request.

        The request infos are saved into the sample result if one is provided.

        Parameters:
        u - URL of the URL request
        method - GET, POST etc
        res - sample result to save request infos to
        Returns:
        HttpURLConnection ready for .connect
        Throws:
        IOException - if an I/O Exception occurs
      • readResponse

        protected byte[] readResponse​(HttpURLConnection conn,
                                      SampleResult res)
                               throws IOException
        Reads the response from the URL connection.
        Parameters:
        conn - URL from which to read response
        res - SampleResult to read response into
        Returns:
        response content
        Throws:
        IOException - if an I/O exception occurs
      • getResponseHeaders

        protected String getResponseHeaders​(HttpURLConnection conn)
        Gets the ResponseHeaders from the URLConnection
        Parameters:
        conn - connection from which the headers are read
        Returns:
        string containing the headers, one per line
      • sample

        protected HTTPSampleResult sample​(URL url,
                                          String method,
                                          boolean areFollowingRedirect,
                                          int frameDepth)
        Samples the URL passed in and stores the result in HTTPSampleResult, following redirects and downloading page resources as appropriate.

        When getting a redirect target, redirects are not followed and resources are not downloaded. The caller will take care of this.

        Specified by:
        sample in class HTTPAbstractImpl
        Parameters:
        url - URL to sample
        method - HTTP method: GET, POST,...
        areFollowingRedirect - whether we're getting a redirect target
        frameDepth - Depth of this target in the frame structure. Used only to prevent infinite recursion.
        Returns:
        results of the sampling
      • interrupt

        public boolean interrupt()
        Interrupt the current operation if possible.
        Returns:
        true if there was an operation to interrupt.