Class ApacheHTTPResponse

  • All Implemented Interfaces:
    HTTPResponse

    final class ApacheHTTPResponse
    extends java.lang.Object
    implements HTTPResponse
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static java.lang.String ACCEPT_ENCODING
      Name of the accept encoding header.
      private static java.lang.String ACCEPT_ENCODING_VAL
      Value to use for the ACCEPT_ENCODING header.
      private AbstractBody body
      The response body which was received from the server or null if that has not yet happened.
      private static java.lang.String CHARSET
      Name of the character set to encode the body to/from.
      private org.apache.http.client.HttpClient client
      HttpClient instance to use to communicate.
      private static java.lang.String CONTENT_TYPE
      Content type to use when transmitting the body data.
      private org.apache.http.protocol.HttpContext context
      The execution state of an HTTP process.
      private java.util.concurrent.locks.Lock lock
      Lock used for internal synchronization.
      private org.apache.http.client.methods.HttpPost post
      The HTTP POST request is sent to the server.
      private boolean sent
      A flag which indicates if the transmission was already done.
      private int statusCode
      The HTTP response status code.
      private BOSHException toThrow
      Exception to throw when the response data is attempted to be accessed, or null if no exception should be thrown.
    • Constructor Summary

      Constructors 
      Constructor Description
      ApacheHTTPResponse​(org.apache.http.client.HttpClient client, BOSHClientConfig cfg, CMSessionParams params, AbstractBody request)
      Create and send a new request to the upstream connection manager, providing deferred access to the results to be returned.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void abort()
      Abort the client transmission and response processing.
      private void awaitResponse()
      Await the response, storing the result in the instance variables of this class when they arrive.
      AbstractBody getBody()
      Wait for and then return the response body.
      int getHTTPStatus()
      Wait for and then return the response HTTP status code.
      • Methods inherited from class java.lang.Object

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

      • ACCEPT_ENCODING

        private static final java.lang.String ACCEPT_ENCODING
        Name of the accept encoding header.
        See Also:
        Constant Field Values
      • ACCEPT_ENCODING_VAL

        private static final java.lang.String ACCEPT_ENCODING_VAL
        Value to use for the ACCEPT_ENCODING header.
      • CHARSET

        private static final java.lang.String CHARSET
        Name of the character set to encode the body to/from.
        See Also:
        Constant Field Values
      • CONTENT_TYPE

        private static final java.lang.String CONTENT_TYPE
        Content type to use when transmitting the body data.
        See Also:
        Constant Field Values
      • lock

        private final java.util.concurrent.locks.Lock lock
        Lock used for internal synchronization.
      • context

        private final org.apache.http.protocol.HttpContext context
        The execution state of an HTTP process.
      • client

        private final org.apache.http.client.HttpClient client
        HttpClient instance to use to communicate.
      • post

        private final org.apache.http.client.methods.HttpPost post
        The HTTP POST request is sent to the server.
      • sent

        private boolean sent
        A flag which indicates if the transmission was already done.
      • toThrow

        private BOSHException toThrow
        Exception to throw when the response data is attempted to be accessed, or null if no exception should be thrown.
      • body

        private AbstractBody body
        The response body which was received from the server or null if that has not yet happened.
      • statusCode

        private int statusCode
        The HTTP response status code.
    • Constructor Detail

      • ApacheHTTPResponse

        ApacheHTTPResponse​(org.apache.http.client.HttpClient client,
                           BOSHClientConfig cfg,
                           CMSessionParams params,
                           AbstractBody request)
        Create and send a new request to the upstream connection manager, providing deferred access to the results to be returned.
        Parameters:
        client - client instance to use when sending the request
        cfg - client configuration
        params - connection manager parameters from the session creation response, or null if the session has not yet been established
        request - body of the client request
    • Method Detail

      • abort

        public void abort()
        Abort the client transmission and response processing.
        Specified by:
        abort in interface HTTPResponse
      • getBody

        public AbstractBody getBody()
                             throws java.lang.InterruptedException,
                                    BOSHException
        Wait for and then return the response body.
        Specified by:
        getBody in interface HTTPResponse
        Returns:
        body of the response
        Throws:
        java.lang.InterruptedException - if interrupted while awaiting the response
        BOSHException - on communication failure
      • getHTTPStatus

        public int getHTTPStatus()
                          throws java.lang.InterruptedException,
                                 BOSHException
        Wait for and then return the response HTTP status code.
        Specified by:
        getHTTPStatus in interface HTTPResponse
        Returns:
        HTTP status code of the response
        Throws:
        java.lang.InterruptedException - if interrupted while awaiting the response
        BOSHException - on communication failure
      • awaitResponse

        private void awaitResponse()
                            throws BOSHException
        Await the response, storing the result in the instance variables of this class when they arrive.
        Throws:
        java.lang.InterruptedException - if interrupted while awaiting the response
        BOSHException - on communication failure