替换部分过期netty方法

master
星期八 5 years ago
parent a6d8dd0860
commit ac67c48357
  1. 5
      proxy-server/src/main/java/org/fengfei/lanproxy/server/config/web/HttpRequestHandler.java

@ -5,6 +5,7 @@ import java.io.RandomAccessFile;
import java.net.URI; import java.net.URI;
import java.nio.charset.Charset; import java.nio.charset.Charset;
import com.alibaba.fastjson.JSONObject;
import io.netty.handler.codec.http.*; import io.netty.handler.codec.http.*;
import org.fengfei.lanproxy.common.JsonUtil; import org.fengfei.lanproxy.common.JsonUtil;
@ -33,7 +34,7 @@ public class HttpRequestHandler extends SimpleChannelInboundHandler<FullHttpRequ
protected void channelRead0(ChannelHandlerContext ctx, FullHttpRequest request) throws Exception { protected void channelRead0(ChannelHandlerContext ctx, FullHttpRequest request) throws Exception {
// GET返回页面;POST请求接口 // GET返回页面;POST请求接口
if (request.getMethod() != HttpMethod.POST) { if (request.method() != HttpMethod.POST) {
outputPages(ctx, request); outputPages(ctx, request);
return; return;
} }
@ -41,7 +42,7 @@ public class HttpRequestHandler extends SimpleChannelInboundHandler<FullHttpRequ
ResponseInfo responseInfo = ApiRoute.run(request); ResponseInfo responseInfo = ApiRoute.run(request);
// 错误码规则:除100取整为http状态码 // 错误码规则:除100取整为http状态码
outputContent(ctx, request, responseInfo.getCode() / 100, JsonUtil.object2json(responseInfo), outputContent(ctx, request, responseInfo.getCode() / 100, JSONObject.toJSONString(responseInfo),
"Application/json;charset=utf-8"); "Application/json;charset=utf-8");
} }

Loading…
Cancel
Save