public final class HttpResponse
extends java.lang.Object
| Constructor and Description |
|---|
HttpResponse(int statusCode,
java.util.List<Header> headers)
Construct a new HttpResponse for an empty response body.
|
HttpResponse(int statusCode,
java.util.List<Header> headers,
byte[] contentBytes)
Construct a new HttpResponse.
|
HttpResponse(int statusCode,
java.util.List<Header> headers,
int contentLength,
java.io.InputStream content)
Construct a new HttpResponse.
|
| Modifier and Type | Method and Description |
|---|---|
java.io.InputStream |
getContent()
Returns an
InputStream of the response content. |
byte[] |
getContentBytes()
If a byte[] was already provided by an HTTP stack that natively supports returning one, this
method will return that byte[] as an optimization over copying the bytes from an input
stream.
|
int |
getContentLength()
Returns the length of the content.
|
java.util.List<Header> |
getHeaders()
Returns the response headers.
|
int |
getStatusCode()
Returns the HTTP status code of the response.
|
public HttpResponse(int statusCode,
java.util.List<Header> headers)
statusCode - the HTTP status code of the responseheaders - the response headerspublic HttpResponse(int statusCode,
java.util.List<Header> headers,
int contentLength,
java.io.InputStream content)
statusCode - the HTTP status code of the responseheaders - the response headerscontentLength - the length of the response content. Ignored if there is no content.content - an InputStream of the response content. May be null to indicate that
the response has no content.public HttpResponse(int statusCode,
java.util.List<Header> headers,
byte[] contentBytes)
statusCode - the HTTP status code of the responseheaders - the response headerscontentBytes - a byte[] of the response content. This is an optimization for HTTP stacks
that natively support returning a byte[].public final int getStatusCode()
public final java.util.List<Header> getHeaders()
public final int getContentLength()
getContent() is non-null.@Nullable public final byte[] getContentBytes()
@Nullable public final java.io.InputStream getContent()
InputStream of the response content. May be null to indicate that the
response has no content.