在上一篇的基础上修改代码
1、TestHttpServerHandle 类
package com.example.firstexample;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;
import io.netty.handler.codec.http.*;
import io.netty.util.CharsetUtil;
import java.net.URI;
public class TestHttpServerHandle extends SimpleChannelInboundHandler{
//读取客户端发送过来的请求,并且向客户端返回响应
protected void channelRead0(ChannelHandlerContext channelHandlerContext, HttpObject httpObject) throws Exception {
CommonUtil.println(httpObject.getClass());
CommonUtil.println(channelHandlerContext.channel().remoteAddress());
if(httpObject instanceof HttpRequest){
HttpRequest httpRequest = (HttpRequest) httpObject;
CommonUtil.println("请求方法名:&