Package org.igniterealtime.jbosh
Class ApacheHTTPResponse
java.lang.Object
org.igniterealtime.jbosh.ApacheHTTPResponse
- All Implemented Interfaces:
HTTPResponse
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final String
Name of the accept encoding header.private static final String
Value to use for the ACCEPT_ENCODING header.private AbstractBody
The response body which was received from the server ornull
if that has not yet happened.private static final String
Name of the character set to encode the body to/from.private final org.apache.http.client.HttpClient
HttpClient instance to use to communicate.private static final String
Content type to use when transmitting the body data.private final org.apache.http.protocol.HttpContext
The execution state of an HTTP process.private final Lock
Lock used for internal synchronization.private final org.apache.http.client.methods.HttpPost
The HTTP POST request is sent to the server.private boolean
A flag which indicates if the transmission was already done.private int
The HTTP response status code.private BOSHException
Exception to throw when the response data is attempted to be accessed, ornull
if no exception should be thrown. -
Constructor Summary
ConstructorsConstructorDescriptionApacheHTTPResponse
(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
Modifier and TypeMethodDescriptionvoid
abort()
Abort the client transmission and response processing.private void
Await the response, storing the result in the instance variables of this class when they arrive.getBody()
Wait for and then return the response body.int
Wait for and then return the response HTTP status code.
-
Field Details
-
ACCEPT_ENCODING
Name of the accept encoding header.- See Also:
-
ACCEPT_ENCODING_VAL
Value to use for the ACCEPT_ENCODING header. -
CHARSET
Name of the character set to encode the body to/from.- See Also:
-
CONTENT_TYPE
Content type to use when transmitting the body data.- See Also:
-
lock
Lock used for internal synchronization. -
context
private final org.apache.http.protocol.HttpContext contextThe execution state of an HTTP process. -
client
private final org.apache.http.client.HttpClient clientHttpClient instance to use to communicate. -
post
private final org.apache.http.client.methods.HttpPost postThe HTTP POST request is sent to the server. -
sent
private boolean sentA flag which indicates if the transmission was already done. -
toThrow
Exception to throw when the response data is attempted to be accessed, ornull
if no exception should be thrown. -
body
The response body which was received from the server ornull
if that has not yet happened. -
statusCode
private int statusCodeThe HTTP response status code.
-
-
Constructor Details
-
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, ornull
if the session has not yet been establishedrequest
- body of the client request
-
-
Method Details
-
abort
public void abort()Abort the client transmission and response processing.- Specified by:
abort
in interfaceHTTPResponse
-
getBody
Wait for and then return the response body.- Specified by:
getBody
in interfaceHTTPResponse
- Returns:
- body of the response
- Throws:
InterruptedException
- if interrupted while awaiting the responseBOSHException
- on communication failure
-
getHTTPStatus
Wait for and then return the response HTTP status code.- Specified by:
getHTTPStatus
in interfaceHTTPResponse
- Returns:
- HTTP status code of the response
- Throws:
InterruptedException
- if interrupted while awaiting the responseBOSHException
- on communication failure
-
awaitResponse
Await the response, storing the result in the instance variables of this class when they arrive.- Throws:
InterruptedException
- if interrupted while awaiting the responseBOSHException
- on communication failure
-