Class HttpUrlConnectionCall


  • public class HttpUrlConnectionCall
    extends ClientCall
    HTTP client connector call based on JDK's java.net.HttpURLConnection class. On the GAE edition, it also supports the SDC protocol by setting automatically the special "use_intranet" header.
    • Field Detail

      • connection

        private final java.net.HttpURLConnection connection
        The wrapped HTTP URL connection.
      • responseHeadersAdded

        private volatile boolean responseHeadersAdded
        Indicates if the response headers were added.
    • Constructor Detail

      • HttpUrlConnectionCall

        public HttpUrlConnectionCall​(HttpClientHelper helper,
                                     java.lang.String method,
                                     java.lang.String requestUri,
                                     boolean hasEntity)
                              throws java.io.IOException
        Constructor.
        Parameters:
        helper - The parent HTTP client helper.
        method - The method name.
        requestUri - The request URI.
        hasEntity - Indicates if the call will have an entity to send to the server.
        Throws:
        java.io.IOException
    • Method Detail

      • getConnection

        public java.net.HttpURLConnection getConnection()
        Returns the connection.
        Returns:
        The connection.
      • getReasonPhrase

        public java.lang.String getReasonPhrase()
        Returns the response reason phrase.
        Overrides:
        getReasonPhrase in class Call
        Returns:
        The response reason phrase.
      • getRepresentation

        protected Representation getRepresentation​(java.io.InputStream stream)
        Description copied from class: Call
        Returns the representation wrapping the given stream.
        Overrides:
        getRepresentation in class Call
        Parameters:
        stream - The response input stream.
        Returns:
        The wrapping representation.
      • getRequestEntityChannel

        public java.nio.channels.WritableByteChannel getRequestEntityChannel()
        Description copied from class: ClientCall
        Returns the request entity channel if it exists.
        Specified by:
        getRequestEntityChannel in class ClientCall
        Returns:
        The request entity channel if it exists.
      • getRequestEntityStream

        public java.io.OutputStream getRequestEntityStream()
        Description copied from class: ClientCall
        Returns the request entity stream if it exists.
        Specified by:
        getRequestEntityStream in class ClientCall
        Returns:
        The request entity stream if it exists.
      • getRequestHeadStream

        public java.io.OutputStream getRequestHeadStream()
        Description copied from class: ClientCall
        Returns the request head stream if it exists.
        Specified by:
        getRequestHeadStream in class ClientCall
        Returns:
        The request head stream if it exists.
      • getRequestStream

        public java.io.OutputStream getRequestStream()
        Returns the request entity stream if it exists.
        Returns:
        The request entity stream if it exists.
      • getResponseEntityChannel

        public java.nio.channels.ReadableByteChannel getResponseEntityChannel​(long size)
        Description copied from class: ClientCall
        Returns the response channel if it exists.
        Specified by:
        getResponseEntityChannel in class ClientCall
        Parameters:
        size - The expected entity size or -1 if unknown.
        Returns:
        The response channel if it exists.
      • getResponseEntityStream

        public java.io.InputStream getResponseEntityStream​(long size)
        Description copied from class: ClientCall
        Returns the response entity stream if it exists.
        Specified by:
        getResponseEntityStream in class ClientCall
        Parameters:
        size - The expected entity size or -1 if unknown.
        Returns:
        The response entity stream if it exists.
      • getResponseHeaders

        public Series<Header> getResponseHeaders()
        Returns the modifiable list of response headers.
        Overrides:
        getResponseHeaders in class Call
        Returns:
        The modifiable list of response headers.
      • getServerAddress

        public java.lang.String getServerAddress()
        Returns the response address.
        Corresponds to the IP address of the responding server.
        Overrides:
        getServerAddress in class Call
        Returns:
        The response address.
      • getStatusCode

        public int getStatusCode()
                          throws java.io.IOException
        Returns the response status code.
        Overrides:
        getStatusCode in class Call
        Returns:
        The response status code.
        Throws:
        java.io.IOException
        java.io.IOException
      • sendRequest

        public Status sendRequest​(Request request)
        Sends the request to the client. Commits the request line, headers and optional entity and send them over the network.
        Overrides:
        sendRequest in class ClientCall
        Parameters:
        request - The high-level request.
        Returns:
        The result status.
      • sendRequest

        public void sendRequest​(Request request,
                                Response response,
                                Uniform callback)
                         throws java.lang.Exception
        Description copied from class: ClientCall
        Sends the request to the client. Commits the request line, headers and optional entity and send them over the network.
        Overrides:
        sendRequest in class ClientCall
        Parameters:
        request - The high-level request.
        response - The high-level response.
        callback - The callback invoked upon request completion.
        Throws:
        java.lang.Exception