Package org.igniterealtime.jbosh
Class ApacheHTTPResponse
- java.lang.Object
-
- org.igniterealtime.jbosh.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.StringACCEPT_ENCODINGName of the accept encoding header.private static java.lang.StringACCEPT_ENCODING_VALValue to use for the ACCEPT_ENCODING header.private AbstractBodybodyThe response body which was received from the server ornullif that has not yet happened.private static java.lang.StringCHARSETName of the character set to encode the body to/from.private org.apache.http.client.HttpClientclientHttpClient instance to use to communicate.private static java.lang.StringCONTENT_TYPEContent type to use when transmitting the body data.private org.apache.http.protocol.HttpContextcontextThe execution state of an HTTP process.private java.util.concurrent.locks.LocklockLock used for internal synchronization.private org.apache.http.client.methods.HttpPostpostThe HTTP POST request is sent to the server.private booleansentA flag which indicates if the transmission was already done.private intstatusCodeThe HTTP response status code.private BOSHExceptiontoThrowException to throw when the response data is attempted to be accessed, ornullif 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 voidabort()Abort the client transmission and response processing.private voidawaitResponse()Await the response, storing the result in the instance variables of this class when they arrive.AbstractBodygetBody()Wait for and then return the response body.intgetHTTPStatus()Wait for and then return the response HTTP status code.
-
-
-
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, ornullif no exception should be thrown.
-
body
private AbstractBody body
The response body which was received from the server ornullif 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 requestcfg- client configurationparams- connection manager parameters from the session creation response, ornullif the session has not yet been establishedrequest- body of the client request
-
-
Method Detail
-
abort
public void abort()
Abort the client transmission and response processing.- Specified by:
abortin interfaceHTTPResponse
-
getBody
public AbstractBody getBody() throws java.lang.InterruptedException, BOSHException
Wait for and then return the response body.- Specified by:
getBodyin interfaceHTTPResponse- Returns:
- body of the response
- Throws:
java.lang.InterruptedException- if interrupted while awaiting the responseBOSHException- on communication failure
-
getHTTPStatus
public int getHTTPStatus() throws java.lang.InterruptedException, BOSHExceptionWait for and then return the response HTTP status code.- Specified by:
getHTTPStatusin interfaceHTTPResponse- Returns:
- HTTP status code of the response
- Throws:
java.lang.InterruptedException- if interrupted while awaiting the responseBOSHException- on communication failure
-
awaitResponse
private void awaitResponse() throws BOSHExceptionAwait the response, storing the result in the instance variables of this class when they arrive.- Throws:
java.lang.InterruptedException- if interrupted while awaiting the responseBOSHException- on communication failure
-
-