@Override
public void handle(ChannelHandlerContext ctx, FullHttpRequest request, String path) throws Exception
{
if (HttpUtil.is100ContinueExpected(request))
ctx.write(new DefaultFullHttpResponse(HTTP_1_1, CONTINUE));
boolean keepAlive = HttpUtil.isKeepAlive(request);
byte[] data = plainTxt ? this.handlePlain() : this.handleWithHTML(ctx, request);
FullHttpResponse response;
if (data == null)
response = new DefaultFullHttpResponse(HTTP_1_1, INTERNAL_SERVER_ERROR);
else
response = new DefaultFullHttpResponse(HTTP_1_1, OK, Unpooled.wrappedBuffer(data));
response.headers().set(CONTENT_TYPE, plainTxt ? "text/plain" : "text/html");
response.headers().setInt(CONTENT_LENGTH, response.content().readableBytes());
if (!keepAlive)
{
ctx.write(response).addListener(ChannelFutureListener.CLOSE);
} else
{
response.headers().set(CONNECTION, KEEP_ALIVE);
ctx.write(response);
}
ctx.flush();
}
DramaHandler.java 文件源码
java
阅读 24
收藏 0
点赞 0
评论 0
项目:DramaGenerator
作者:
评论列表
文章目录