public class NettyWebResponse extends java.lang.Object implements WebResponse, HttpConstants
| Modifier and Type | Field and Description |
|---|---|
protected io.netty.channel.Channel |
channel |
protected int |
code |
protected io.netty.channel.ChannelHandlerContext |
ctx |
protected java.util.concurrent.atomic.AtomicBoolean |
first |
protected java.util.HashMap<java.lang.String,java.lang.String> |
headers |
protected java.util.HashMap<java.lang.String,java.lang.Object> |
properties
Custom properties (for inter-middleware communication).
|
protected NettyWebRequest |
req |
ACCEPT, ACCEPT_ENCODING, AUTHORIZATION, CACHE_CONTROL, CHUNKED, CLOSE, CONNECT, CONNECTION, CONTENT_ENCODING, CONTENT_LENGTH, CONTENT_TYPE, CONTENT_TYPE_HTML, CONTENT_TYPE_JSON, COOKIE, DEFLATE, DELETE, ETAG, GET, GZIP, HEAD, IF_NONE_MATCH, KEEP_ALIVE, LOCATION, META_CONTENT_TYPE, META_HEADERS, META_LOCALE, META_LOCATION, META_SESSION, META_STATUS, META_TEMPLATE, NO_CACHE, OPTIONS, PATCH, POST, PROPERTY_COOKIES, PROPERTY_SESSION_ID, PROPERTY_USER, PUT, SET_COOKIE, TRACE, TRANSFER_ENCODING, WWW_AUTHENTICATE, X_FORWARDED_FOR| Constructor and Description |
|---|
NettyWebResponse(io.netty.channel.ChannelHandlerContext ctx,
NettyWebRequest req) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
end()
Completes the asynchronous operation that was started on the request.
|
java.lang.String |
getHeader(java.lang.String name)
Returns the value of the specified response header as a String.
|
java.lang.Object |
getInternalObject()
Returns the internal object of this WebResponse.
|
java.lang.Object |
getProperty(java.lang.String name)
Returns the value to which the specified "name" is mapped, or null if
this WebResponse contains no mapping for the "name".
|
int |
getStatus()
Gets the current status code of this response.
|
void |
send(byte[] bytes)
Writes b.length bytes of body from the specified byte array to the output
stream.
|
protected void |
sendHeaders() |
void |
setHeader(java.lang.String name,
java.lang.String value)
Sets a response header with the given name and value.
|
void |
setProperty(java.lang.String name,
java.lang.Object value)
Associates the specified value with the specified "name" in this
WebResponse.
|
void |
setStatus(int code)
Sets the status code for this response.
|
protected final io.netty.channel.ChannelHandlerContext ctx
protected final NettyWebRequest req
protected final io.netty.channel.Channel channel
protected java.util.HashMap<java.lang.String,java.lang.Object> properties
protected int code
protected java.util.HashMap<java.lang.String,java.lang.String> headers
protected java.util.concurrent.atomic.AtomicBoolean first
public NettyWebResponse(io.netty.channel.ChannelHandlerContext ctx,
NettyWebRequest req)
public void setStatus(int code)
setStatus in interface WebResponsecode - the status codepublic int getStatus()
getStatus in interface WebResponsepublic void setHeader(java.lang.String name,
java.lang.String value)
setHeader in interface WebResponsename - the name of the headervalue - the header value If it contains octet string, it should be
encoded according to RFC 2047public java.lang.String getHeader(java.lang.String name)
getHeader in interface WebResponsename - name a String specifying the header namepublic void send(byte[] bytes)
throws java.io.IOException
send in interface WebResponsebytes - the datajava.io.IOException - if an I/O error occurspublic boolean end()
end in interface WebResponseprotected void sendHeaders()
public void setProperty(java.lang.String name,
java.lang.Object value)
setProperty in interface WebResponsename - a "name" with which the specified value is to be associatedvalue - value to be associated with the specified "name"public java.lang.Object getProperty(java.lang.String name)
getProperty in interface WebResponsename - the "name" whose associated value is to be returnedpublic java.lang.Object getInternalObject()
getInternalObject in interface WebResponse