public class Response
extends java.lang.Object
| Modifier and Type | Class and Description |
|---|---|
static class |
Response.Code
Common HTTP response codes.
|
| Modifier and Type | Field and Description |
|---|---|
<any> |
attributes
An immutable map of attributes.
|
<any> |
headers
An immutable map of headers.
|
int |
statusCode
The status code.
|
| Constructor and Description |
|---|
Response(int statusCode,
java.util.Map<?,?> headers)
Creates a response.
|
Response(int statusCode,
java.util.Map<?,?> headers,
java.util.Map<java.lang.String,java.lang.Object> attributes)
Creates a response with attributes.
|
| Modifier and Type | Method and Description |
|---|---|
java.lang.Object |
getAttribute(java.lang.String name)
Gets an attribute.
|
ByteString |
getBody()
Gets the response body as an immutable
ByteString. |
java.lang.String |
getCharset(java.lang.String defaultCharset)
Gets the charset specified for this response or the default
charset if none specified.
|
java.lang.String |
getContentType()
Gets the value of the
Content-Type header. |
java.util.Collection<Header> |
getHeaders()
Gets all headers.
|
java.lang.String |
getHeaderValue(java.lang.String name)
Gets the first header value.
|
<any> |
getHeaderValueList(java.lang.String name)
Gets an immutable list of values for a header.
|
java.lang.String[] |
getHeaderValues(java.lang.String name)
Gets all values for a header.
|
int |
getStatusCode()
Gets the HTTP response code.
|
java.lang.String |
toString() |
public final int statusCode
public final <any> headers
The keys in this map are lower-case.
public final <any> attributes
Beware: The values may not be immutable.
public Response(int statusCode,
java.util.Map<?,?> headers)
statusCode - The HTTP response status code.headers - The response headers.public Response(int statusCode,
java.util.Map<?,?> headers,
java.util.Map<java.lang.String,java.lang.Object> attributes)
statusCode - The HTTP response status code.headers - The response headers.attributes - The attributes.public int getStatusCode()
public ByteString getBody()
throws java.io.IOException
ByteString.null if none.java.io.IOException - if the body is streamed and an input error occurs.public java.lang.String getHeaderValue(java.lang.String name)
name - The header name.null if none.public java.lang.String[] getHeaderValues(java.lang.String name)
name - The header name.null if none.public <any> getHeaderValueList(java.lang.String name)
name - The header name.null if none.public java.lang.String getContentType()
Content-Type header.null if none.public java.lang.String getCharset(java.lang.String defaultCharset)
defaultCharset - The default charset.public java.util.Collection<Header> getHeaders()
public java.lang.Object getAttribute(java.lang.String name)
name - The attribute name.null if none set.public java.lang.String toString()
toString in class java.lang.Object