public class NettyHttpResponse extends Object implements HttpResponse
| 限定符和类型 | 字段和说明 |
|---|---|
private Charset |
charset |
private org.jboss.netty.channel.ChannelHandlerContext |
ctx |
private static Charset |
DEFAULT_CHARSET |
private Thread.UncaughtExceptionHandler |
exceptionHandler |
private boolean |
isKeepAlive |
private org.jboss.netty.handler.codec.http.HttpResponse |
response |
private org.jboss.netty.buffer.ChannelBuffer |
responseBuffer |
| 构造器和说明 |
|---|
NettyHttpResponse(org.jboss.netty.channel.ChannelHandlerContext ctx,
org.jboss.netty.handler.codec.http.HttpResponse response,
boolean isKeepAlive,
Thread.UncaughtExceptionHandler exceptionHandler) |
| 限定符和类型 | 方法和说明 |
|---|---|
Charset |
charset()
Current Charset used to encode to response as.
|
NettyHttpResponse |
charset(Charset charset)
For text based responses, sets the Charset to encode the response as.
|
NettyHttpResponse |
chunked()
Turns the response into a chunked response
after this method is called,
HttpResponse.write(String) should be used to send chunks |
boolean |
containsHeader(String name)
Test to see if this response has a header of the specified name
|
NettyHttpResponse |
content(byte[] content)
Write binary based content back to the client.
|
NettyHttpResponse |
content(ByteBuffer buffer)
Write binary based content back to the client.
|
private NettyHttpResponse |
content(org.jboss.netty.buffer.ChannelBuffer content) |
NettyHttpResponse |
content(String content)
Write text based content back to the client.
|
NettyHttpResponse |
cookie(HttpCookie httpCookie)
Adds a cookie
|
NettyHttpResponse |
end()
Marks the response as ended.
|
NettyHttpResponse |
error(Throwable error)
Marks the response as erroneous.
|
private void |
flushResponse() |
private String |
getStackTrace(Throwable error) |
NettyHttpResponse |
header(String name,
Date value)
Adds a Date (RFC 1123 format) HTTP header.
|
NettyHttpResponse |
header(String name,
long value)
Adds a numeric HTTP header.
|
NettyHttpResponse |
header(String name,
String value)
Adds an HTTP header.
|
int |
status()
Retrieve HTTP status code that this response is going to return.
|
NettyHttpResponse |
status(int status)
Sets the HTTP status code.
|
private org.jboss.netty.channel.ChannelFuture |
write(org.jboss.netty.buffer.ChannelBuffer responseBuffer) |
NettyHttpResponse |
write(String content)
Writes immediately to the client without closing the connection.
|
private static final Charset DEFAULT_CHARSET
private final org.jboss.netty.channel.ChannelHandlerContext ctx
private final org.jboss.netty.handler.codec.http.HttpResponse response
private final boolean isKeepAlive
private final Thread.UncaughtExceptionHandler exceptionHandler
private final org.jboss.netty.buffer.ChannelBuffer responseBuffer
private Charset charset
public NettyHttpResponse(org.jboss.netty.channel.ChannelHandlerContext ctx,
org.jboss.netty.handler.codec.http.HttpResponse response,
boolean isKeepAlive,
Thread.UncaughtExceptionHandler exceptionHandler)
public NettyHttpResponse charset(Charset charset)
HttpResponsecharset 在接口中 HttpResponsepublic Charset charset()
HttpResponsecharset 在接口中 HttpResponseHttpResponse.charset(java.nio.charset.Charset)public NettyHttpResponse status(int status)
HttpResponsestatus 在接口中 HttpResponsepublic NettyHttpResponse chunked()
HttpResponseHttpResponse.write(String) should be used to send chunkschunked 在接口中 HttpResponsepublic int status()
HttpResponsestatus 在接口中 HttpResponseHttpResponse.status(int)public NettyHttpResponse header(String name, String value)
HttpResponseheader 在接口中 HttpResponsepublic NettyHttpResponse header(String name, long value)
HttpResponseheader 在接口中 HttpResponsepublic NettyHttpResponse header(String name, Date value)
HttpResponseheader 在接口中 HttpResponsepublic boolean containsHeader(String name)
HttpResponsecontainsHeader 在接口中 HttpResponsepublic NettyHttpResponse cookie(HttpCookie httpCookie)
HttpResponsecookie 在接口中 HttpResponsehttpCookie - the cookiepublic NettyHttpResponse content(String content)
HttpResponsepublic NettyHttpResponse content(byte[] content)
HttpResponsecontent 在接口中 HttpResponseHttpResponse.content(String)public NettyHttpResponse content(ByteBuffer buffer)
HttpResponsecontent 在接口中 HttpResponseHttpResponse.content(String)private NettyHttpResponse content(org.jboss.netty.buffer.ChannelBuffer content)
public NettyHttpResponse write(String content)
HttpResponseHttpResponse.content(String) method caches content until HttpResponse.end() is called()
TODO: Make content write immediately instead and remove this method?write 在接口中 HttpResponsecontent - what to writepublic NettyHttpResponse error(Throwable error)
HttpResponseHttpResponse.end() or HttpResponse.error(Throwable) called. No more
operations should be performed on a response after these.error 在接口中 HttpResponsepublic NettyHttpResponse end()
HttpResponseHttpResponse.end() or HttpResponse.error(Throwable) called. No more
operations should be performed on a response after these.end 在接口中 HttpResponseprivate void flushResponse()
private org.jboss.netty.channel.ChannelFuture write(org.jboss.netty.buffer.ChannelBuffer responseBuffer)
Copyright © 2014. All rights reserved.