public class HttpResponse
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private java.io.InputStream |
content |
private java.util.Map<java.lang.String,java.lang.String> |
headers |
private org.apache.http.client.methods.HttpRequestBase |
httpRequest |
private Request<?> |
request |
private int |
statusCode |
private java.lang.String |
statusText |
Constructor and Description |
---|
HttpResponse(Request<?> request,
org.apache.http.client.methods.HttpRequestBase httpRequest)
Constructs a new HttpResponse associated with the specified request.
|
Modifier and Type | Method and Description |
---|---|
void |
addHeader(java.lang.String name,
java.lang.String value)
Adds an HTTP header to the set associated with this response.
|
java.io.InputStream |
getContent()
Returns the input stream containing the response content.
|
java.util.Map<java.lang.String,java.lang.String> |
getHeaders()
Returns the HTTP headers returned with this response.
|
org.apache.http.client.methods.HttpRequestBase |
getHttpRequest()
Returns the original http request associated with this response.
|
Request<?> |
getRequest()
Returns the original request associated with this response.
|
int |
getStatusCode()
Returns the HTTP status code (ex: 200, 404, etc) associated with this
response.
|
java.lang.String |
getStatusText()
Returns the HTTP status text associated with this response.
|
void |
setContent(java.io.InputStream content)
Sets the input stream containing the response content.
|
void |
setStatusCode(int statusCode)
Sets the HTTP status code that was returned with this response.
|
void |
setStatusText(java.lang.String statusText)
Sets the HTTP status text returned with this response.
|
private final Request<?> request
private final org.apache.http.client.methods.HttpRequestBase httpRequest
private java.lang.String statusText
private int statusCode
private java.io.InputStream content
private java.util.Map<java.lang.String,java.lang.String> headers
public HttpResponse(Request<?> request, org.apache.http.client.methods.HttpRequestBase httpRequest)
request
- The associated request that generated this response.httpRequest
- The underlying http request that generated this response.public Request<?> getRequest()
public org.apache.http.client.methods.HttpRequestBase getHttpRequest()
public java.util.Map<java.lang.String,java.lang.String> getHeaders()
public void addHeader(java.lang.String name, java.lang.String value)
name
- The name of the HTTP header.value
- The value of the HTTP header.public void setContent(java.io.InputStream content)
content
- The input stream containing the response content.public java.io.InputStream getContent()
public void setStatusText(java.lang.String statusText)
statusText
- The HTTP status text (ex: "Not found") returned with this
response.public java.lang.String getStatusText()
public void setStatusCode(int statusCode)
statusCode
- The HTTP status code (ex: 200, 404, etc) associated with this
response.public int getStatusCode()