public class Response
extends java.lang.Object
implements io.netty.handler.codec.http.FullHttpResponse
| Constructor and Description |
|---|
Response(Server server,
io.netty.channel.Channel channel,
Request request,
io.netty.handler.codec.http.router.RouteResult routeResult) |
| Modifier and Type | Method and Description |
|---|---|
io.netty.buffer.ByteBuf |
content() |
io.netty.handler.codec.http.FullHttpResponse |
copy() |
io.netty.handler.codec.DecoderResult |
decoderResult() |
boolean |
doneResponding() |
io.netty.handler.codec.http.FullHttpResponse |
duplicate() |
io.netty.handler.codec.DecoderResult |
getDecoderResult() |
io.netty.handler.codec.http.HttpVersion |
getProtocolVersion() |
io.netty.handler.codec.http.HttpResponseStatus |
getStatus() |
io.netty.handler.codec.http.HttpHeaders |
headers() |
io.netty.handler.codec.http.HttpVersion |
protocolVersion() |
int |
refCnt() |
boolean |
release() |
boolean |
release(int arg0) |
java.lang.String |
renderEventSource(java.lang.Object data) |
java.lang.String |
renderEventSource(java.lang.Object data,
java.lang.String event) |
io.netty.handler.codec.http.FullHttpResponse |
replace(io.netty.buffer.ByteBuf content) |
io.netty.channel.ChannelFuture |
respond() |
io.netty.channel.ChannelFuture |
respondBinary(byte[] bytes)
If Content-Type header is not set, it is set to "application/octet-stream".
|
io.netty.channel.ChannelFuture |
respondBinary(io.netty.buffer.ByteBuf byteBuf)
If Content-Type header is not set, it is set to "application/octet-stream".
|
io.netty.channel.ChannelFuture |
respondEventSource(java.lang.Object data)
To respond event source, call this method as many time as you want.
|
io.netty.channel.ChannelFuture |
respondEventSource(java.lang.Object data,
java.lang.String event)
To respond event source, call this method as many time as you want.
|
io.netty.channel.ChannelFuture |
respondFile(java.io.File file) |
io.netty.channel.ChannelFuture |
respondFile(java.lang.String filePath) |
io.netty.channel.ChannelFuture |
respondHtml(java.lang.Object any)
Content-Type header is set to "text/html".
|
io.netty.channel.ChannelFuture |
respondJs(java.lang.Object any)
Content-Type header is set to "application/javascript".
|
io.netty.channel.ChannelFuture |
respondJson(java.lang.Object ref)
Converts the given Java object to JSON object using Jackson ObjectMapper,
and responds it.
|
io.netty.channel.ChannelFuture |
respondJsonP(java.lang.Object ref,
java.lang.String function)
Converts the given Java object to JSON object using Jackson ObjectMapper,
wraps it with the given JavaScript function name, and responds.
|
io.netty.channel.ChannelFuture |
respondJsonPText(java.lang.Object text,
java.lang.String function)
Wraps the text with the given JavaScript function name, and responds.
|
io.netty.channel.ChannelFuture |
respondJsonText(java.lang.Object any)
Content-Type header is set to "application/json".
|
io.netty.channel.ChannelFuture |
respondText(java.lang.Object text) |
io.netty.channel.ChannelFuture |
respondText(java.lang.Object text,
java.lang.String fallbackContentType) |
io.netty.channel.ChannelFuture |
respondXml(java.lang.Object any)
Content-Type header is set to "application/xml".
|
io.netty.handler.codec.http.FullHttpResponse |
retain() |
io.netty.handler.codec.http.FullHttpResponse |
retain(int arg0) |
io.netty.handler.codec.http.FullHttpResponse |
retainedDuplicate() |
void |
setClientCacheAggressively() |
void |
setDecoderResult(io.netty.handler.codec.DecoderResult arg0) |
void |
setNoClientCache() |
io.netty.handler.codec.http.FullHttpResponse |
setProtocolVersion(io.netty.handler.codec.http.HttpVersion arg0) |
io.netty.handler.codec.http.FullHttpResponse |
setStatus(io.netty.handler.codec.http.HttpResponseStatus arg0) |
io.netty.handler.codec.http.HttpResponseStatus |
status() |
java.lang.String |
toString() |
io.netty.handler.codec.http.FullHttpResponse |
touch() |
io.netty.handler.codec.http.FullHttpResponse |
touch(java.lang.Object hint) |
io.netty.handler.codec.http.HttpHeaders |
trailingHeaders() |
public boolean doneResponding()
public void setClientCacheAggressively()
public void setNoClientCache()
public io.netty.channel.ChannelFuture respond()
throws java.lang.Exception
java.lang.Exceptionpublic io.netty.channel.ChannelFuture respondText(java.lang.Object text)
throws java.lang.Exception
java.lang.Exceptionpublic io.netty.channel.ChannelFuture respondText(java.lang.Object text,
java.lang.String fallbackContentType)
throws java.lang.Exception
fallbackContentType - Only used if Content-Type header has not been set.
If not given and Content-Type header is not set, it is set to
"application/xml" if text param is Node or NodeSeq, otherwise it is
set to "text/plain".java.lang.Exceptionpublic io.netty.channel.ChannelFuture respondXml(java.lang.Object any)
throws java.lang.Exception
java.lang.Exceptionpublic io.netty.channel.ChannelFuture respondHtml(java.lang.Object any)
throws java.lang.Exception
java.lang.Exceptionpublic io.netty.channel.ChannelFuture respondJs(java.lang.Object any)
throws java.lang.Exception
java.lang.Exceptionpublic io.netty.channel.ChannelFuture respondJsonText(java.lang.Object any)
throws java.lang.Exception
java.lang.Exceptionpublic io.netty.channel.ChannelFuture respondJson(java.lang.Object ref)
throws java.lang.Exception
Content-Type header is set to "application/json". "text/json" would make the browser download instead of displaying the content. It makes debugging a pain.
java.lang.Exceptionpublic io.netty.channel.ChannelFuture respondJsonPText(java.lang.Object text,
java.lang.String function)
throws java.lang.Exception
Content-Type header is set to "application/javascript".
java.lang.Exceptionpublic io.netty.channel.ChannelFuture respondJsonP(java.lang.Object ref,
java.lang.String function)
throws java.lang.Exception
Content-Type header is set to "application/javascript".
java.lang.Exceptionpublic io.netty.channel.ChannelFuture respondBinary(byte[] bytes)
throws java.lang.Exception
java.lang.Exceptionpublic io.netty.channel.ChannelFuture respondBinary(io.netty.buffer.ByteBuf byteBuf)
throws java.lang.Exception
byteBuf - Will be releasedjava.lang.Exceptionpublic io.netty.channel.ChannelFuture respondFile(java.lang.String filePath)
public io.netty.channel.ChannelFuture respondFile(java.io.File file)
public java.lang.String renderEventSource(java.lang.Object data)
public java.lang.String renderEventSource(java.lang.Object data,
java.lang.String event)
public io.netty.channel.ChannelFuture respondEventSource(java.lang.Object data)
throws java.lang.Exception
Event Source response is a special kind of chunked response, data must be UTF-8. See: - http://sockjs.github.com/sockjs-protocol/sockjs-protocol-0.3.3.html#section-94 - http://dev.w3.org/html5/eventsource/
No need to call setChunked() before calling this method.
java.lang.Exceptionpublic io.netty.channel.ChannelFuture respondEventSource(java.lang.Object data,
java.lang.String event)
throws java.lang.Exception
Event Source response is a special kind of chunked response, data must be UTF-8. See: - http://sockjs.github.com/sockjs-protocol/sockjs-protocol-0.3.3.html#section-94 - http://dev.w3.org/html5/eventsource/
No need to call setChunked() before calling this method.
java.lang.Exceptionpublic io.netty.handler.codec.http.HttpResponseStatus getStatus()
getStatus in interface io.netty.handler.codec.http.HttpResponsepublic io.netty.handler.codec.http.HttpResponseStatus status()
status in interface io.netty.handler.codec.http.HttpResponsepublic io.netty.handler.codec.http.HttpVersion getProtocolVersion()
getProtocolVersion in interface io.netty.handler.codec.http.HttpMessagepublic io.netty.handler.codec.http.HttpVersion protocolVersion()
protocolVersion in interface io.netty.handler.codec.http.HttpMessagepublic io.netty.handler.codec.http.HttpHeaders headers()
headers in interface io.netty.handler.codec.http.HttpMessagepublic io.netty.handler.codec.DecoderResult getDecoderResult()
getDecoderResult in interface io.netty.handler.codec.http.HttpObjectpublic io.netty.handler.codec.DecoderResult decoderResult()
decoderResult in interface io.netty.handler.codec.DecoderResultProviderpublic void setDecoderResult(io.netty.handler.codec.DecoderResult arg0)
setDecoderResult in interface io.netty.handler.codec.DecoderResultProviderpublic io.netty.handler.codec.http.HttpHeaders trailingHeaders()
trailingHeaders in interface io.netty.handler.codec.http.LastHttpContentpublic io.netty.handler.codec.http.FullHttpResponse retainedDuplicate()
retainedDuplicate in interface io.netty.buffer.ByteBufHolderretainedDuplicate in interface io.netty.handler.codec.http.FullHttpMessageretainedDuplicate in interface io.netty.handler.codec.http.FullHttpResponseretainedDuplicate in interface io.netty.handler.codec.http.HttpContentretainedDuplicate in interface io.netty.handler.codec.http.LastHttpContentpublic io.netty.handler.codec.http.FullHttpResponse replace(io.netty.buffer.ByteBuf content)
replace in interface io.netty.buffer.ByteBufHolderreplace in interface io.netty.handler.codec.http.FullHttpMessagereplace in interface io.netty.handler.codec.http.FullHttpResponsereplace in interface io.netty.handler.codec.http.HttpContentreplace in interface io.netty.handler.codec.http.LastHttpContentpublic io.netty.buffer.ByteBuf content()
content in interface io.netty.buffer.ByteBufHolderpublic int refCnt()
refCnt in interface io.netty.util.ReferenceCountedpublic boolean release()
release in interface io.netty.util.ReferenceCountedpublic boolean release(int arg0)
release in interface io.netty.util.ReferenceCountedpublic io.netty.handler.codec.http.FullHttpResponse copy()
copy in interface io.netty.buffer.ByteBufHoldercopy in interface io.netty.handler.codec.http.FullHttpMessagecopy in interface io.netty.handler.codec.http.FullHttpResponsecopy in interface io.netty.handler.codec.http.HttpContentcopy in interface io.netty.handler.codec.http.LastHttpContentpublic io.netty.handler.codec.http.FullHttpResponse duplicate()
duplicate in interface io.netty.buffer.ByteBufHolderduplicate in interface io.netty.handler.codec.http.FullHttpMessageduplicate in interface io.netty.handler.codec.http.FullHttpResponseduplicate in interface io.netty.handler.codec.http.HttpContentduplicate in interface io.netty.handler.codec.http.LastHttpContentpublic io.netty.handler.codec.http.FullHttpResponse retain()
retain in interface io.netty.buffer.ByteBufHolderretain in interface io.netty.handler.codec.http.FullHttpMessageretain in interface io.netty.handler.codec.http.FullHttpResponseretain in interface io.netty.handler.codec.http.HttpContentretain in interface io.netty.handler.codec.http.LastHttpContentretain in interface io.netty.util.ReferenceCountedpublic io.netty.handler.codec.http.FullHttpResponse touch()
touch in interface io.netty.buffer.ByteBufHoldertouch in interface io.netty.handler.codec.http.FullHttpMessagetouch in interface io.netty.handler.codec.http.FullHttpResponsetouch in interface io.netty.handler.codec.http.HttpContenttouch in interface io.netty.handler.codec.http.LastHttpContenttouch in interface io.netty.util.ReferenceCountedpublic io.netty.handler.codec.http.FullHttpResponse touch(java.lang.Object hint)
touch in interface io.netty.buffer.ByteBufHoldertouch in interface io.netty.handler.codec.http.FullHttpMessagetouch in interface io.netty.handler.codec.http.FullHttpResponsetouch in interface io.netty.handler.codec.http.HttpContenttouch in interface io.netty.handler.codec.http.LastHttpContenttouch in interface io.netty.util.ReferenceCountedpublic io.netty.handler.codec.http.FullHttpResponse retain(int arg0)
retain in interface io.netty.buffer.ByteBufHolderretain in interface io.netty.handler.codec.http.FullHttpMessageretain in interface io.netty.handler.codec.http.FullHttpResponseretain in interface io.netty.handler.codec.http.HttpContentretain in interface io.netty.handler.codec.http.LastHttpContentretain in interface io.netty.util.ReferenceCountedpublic io.netty.handler.codec.http.FullHttpResponse setProtocolVersion(io.netty.handler.codec.http.HttpVersion arg0)
setProtocolVersion in interface io.netty.handler.codec.http.FullHttpResponsesetProtocolVersion in interface io.netty.handler.codec.http.HttpMessagesetProtocolVersion in interface io.netty.handler.codec.http.HttpResponsepublic io.netty.handler.codec.http.FullHttpResponse setStatus(io.netty.handler.codec.http.HttpResponseStatus arg0)
setStatus in interface io.netty.handler.codec.http.FullHttpResponsesetStatus in interface io.netty.handler.codec.http.HttpResponsepublic java.lang.String toString()
toString in class java.lang.Object