monkeyWie / proxyee

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

FullHttpRequest如何获取完整的正确url? #130

Closed dujianchi closed 3 years ago

dujianchi commented 3 years ago

我拦截到请求FullHttpRequest的时候,想要获取正确的url,假设原始请求如下:

https://www.example.org/aaa
http://bbb.example.org/ccc
https://ddd.example.org/eee

我通过FullHttpRequest.url()取到了:

/aaa
/ccc
/eee

然后又通过FullHttpRequest.headers().get("Host")取到了:

www.example.org
bbb.example.org
ddd.example.org

但是这个host是不带协议的,我无法判断它实际上是https还是http,我该如何获取如下的完整url?

https://www.example.org/aaa
http://bbb.example.org/ccc
https://ddd.example.org/eee
dujianchi commented 3 years ago

发现 public void handleRequest(FullHttpRequest httpRequest, HttpProxyInterceptPipeline pipeline) 中的HttpProxyInterceptPipeline.getRequestProto()有是否是ssl的判断,可以直接用这个判断吗?

monkeyWie commented 3 years ago

@dujianchi 可以的,原始的请求信息都在HttpProxyInterceptPipeline.getRequestProto()里面。