HttpProxyServerConfig config = new HttpProxyServerConfig();
//enable HTTPS support
//If not enabled, HTTPS will not be intercepted, but forwarded directly to the raw packet.
config.setHandleSsl(true);
new HttpProxyServer()
.serverConfig(config)
.proxyInterceptInitializer(new HttpProxyInterceptInitializer() {
@Override
public void init(HttpProxyInterceptPipeline pipeline) {
pipeline.addLast(new FullResponseIntercept() {
@Override
public boolean match(HttpRequest httpRequest, HttpResponse httpResponse,
HttpProxyInterceptPipeline pipeline) {
//Insert js when matching to Baidu homepage
return true;
}
@Override
public void handleResponse(HttpRequest httpRequest, FullHttpResponse httpResponse,
HttpProxyInterceptPipeline pipeline) {
//Print raw packet
System.out.println(httpResponse.toString());
System.out.println(httpResponse.content().toString(Charset.defaultCharset()));
//Edit response header and response body
}
});
}
})
.start(28888);
hi,
13:21:23.491 [nioEventLoopGroup-3-1] DEBUG io.netty.handler.logging.LoggingHandler - [id: 0xe536e86a, L:/0:0:0:0:0:0:0:0:28888] READ: [id: 0x6799de55, L:/127.0.0.1:28888 - R:/127.0.0.1:53677] 13:21:23.491 [nioEventLoopGroup-3-1] DEBUG io.netty.handler.logging.LoggingHandler - [id: 0xe536e86a, L:/0:0:0:0:0:0:0:0:28888] READ COMPLETE
代码部分如下 public static void start() {
HttpProxyServerConfig config = new HttpProxyServerConfig(); //enable HTTPS support //If not enabled, HTTPS will not be intercepted, but forwarded directly to the raw packet. config.setHandleSsl(true); new HttpProxyServer() .serverConfig(config) .proxyInterceptInitializer(new HttpProxyInterceptInitializer() { @Override public void init(HttpProxyInterceptPipeline pipeline) { pipeline.addLast(new FullResponseIntercept() { @Override public boolean match(HttpRequest httpRequest, HttpResponse httpResponse, HttpProxyInterceptPipeline pipeline) { //Insert js when matching to Baidu homepage return true; }
}
请问有什么好的排查思路么,因为怀疑项目的依赖包版本冲突,我已经把netty的版本都升级到4.1.59.Final