monkeyWie / proxyee

HTTP proxy server,support HTTPS&websocket.MITM impl,intercept and tamper HTTPS traffic.
MIT License
1.53k stars 573 forks source link

拦截请求后自定义请求和响应返回,如何实现? #87

Open 772451348 opened 4 years ago

monkeyWie commented 4 years ago

参考:https://github.com/monkeyWie/proxyee/blob/master/src/test/java/com/github/monkeywie/proxyee/InterceptFullHttpProxyServer.java

hzceo commented 4 years ago

这个两个match同时返回true会用不了

luyuanwan commented 4 years ago

拦截请求自定义处理有个不方便的地方,就是只能有1对出现,见下方代码, 如果2个Response都要处理的话就会报错

 pipeline.addLast(new FullResponseIntercept() {
      @Override
      public boolean match(HttpRequest httpRequest, HttpResponse httpResponse, HttpProxyInterceptPipeline pipeline) {
                 return true;
     }
      @Override
       public void handelResponse(HttpRequest httpRequest, FullHttpResponse httpResponse, HttpProxyInterceptPipeline pipeline) {
              //TODO
       }
});
monkeyWie commented 4 years ago

@luyuanwan 只会有一个Response呀,没懂你的意思。