monkeyWie / proxyee

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

FullHttpResponse 解析中文概率乱码 #101

Open nsioo opened 3 years ago

nsioo commented 3 years ago

override fun handleResponse(httpRequest: HttpRequest, httpResponse: FullHttpResponse, pipeline: HttpProxyInterceptPipeline) { //打印原始响应信息

                    Log.e("------res1-----", httpResponse.toString());
                    Log.e("------mitm res1-----", httpResponse.content().toString(Charset.defaultCharset()) );
                    Log.e("------mitm res2-----", httpResponse.content().toString(Charset.forName("gbk")) );

}

如题,请教是否设置有问题? ///////////////////////////////////////////////////////////

2020-10-10 16:28:25.565 23094-23364/com.ptlife.spcc.starcc E/------res1-----: HttpObjectAggregator$AggregatedFullHttpResponse(decodeResult: success, version: HTTP/1.1, content: CompositeByteBuf(ridx: 0, widx: 124, cap: 124, components=1)) HTTP/1.1 200 OK Server: Tengine Content-Type: application/json; charset=utf-8 Connection: keep-alive Date: Sat, 10 Oct 2020 08:28:24 GMT x-janus-mini-api-forward: Janus-Mini(fast) x-krakend: Version 2 x-krakend-completed: false status_code: 0 tt_stable: 1 x-tt-logid: 2020101016282401012912820402046358 bd-tt-error-code: 0 rip: api5-normal-c-lq.amemv.com vary: Accept-Encoding content-encoding: br tt-idc-switch: 10000@20200922002 Access-Control-Expose-Headers: tt-idc-switch server-timing: inner; dur=16 x-tt-trace-host: 010898853b0c09a4ca34d6d8f4cd22c57396c699aa7192df1127231d44bf57a809e59e49601b29abc183ac5112b60ced041844ee800c05b3f613c5978dd294002cac1f8fde960545d364efaa2070189ed4 x-tt-trace-tag: id=3;cdn-cache=miss x-tt-trace-id: 00-11a015540d977ab7cc82eeec25120468-11a015540d977ab7-01 server-timing: cdn-cache;desc=MISS,edge;dur=0,origin;dur=57 Via: cache17.cn1808[57,0] Timing-Allow-Origin: EagleId: 6f7b37a516023185045275939e content-length: 124 2020-10-10 16:28:25.565 23094-23364/com.ptlife.spcc.starcc E/------res2-----: ]����Ġy}%^~L�NN�bxX�ڂ��S��nc����(����o�FG�~-���>F�y�P�U�ZC�Pl9�&,�n�O8�!U�t��"��.����l���?��pJz�����K 2020-10-10 16:28:25.567 23094-23364/com.ptlife.spcc.starcc E/------mitm res1-----: ]����Ġy}%^~L�NN�bxX�ڂ��S��nc����(����o�FG�~-���>F�y�P�U�ZC�Pl9�&,�n�O8�!U�t��"��.����l���?��pJz�����K 2020-10-10 16:28:25.569 23094-23364/com.ptlife.spcc.starcc E/------mitm res2-----: ]����臓y}%^~L哊N鴅xX勤���S揉nc冕宴(倸��o�FG貇-���>F脃癀P躑萙C�Pl9�&,猲乣O8�!U秚№竼"掴.�雔呫�?┨pJz荚勪K 2020-10-10 16:28:25.570 23094-23364/com.ptlife.spcc.starcc E/------mitm header-----: DefaultHttpHeaders[Server: Tengine, Content-Type: application/json; charset=utf-8, Connection: keep-alive, Date: Sat, 10 Oct 2020 08:28:24 GMT, x-janus-mini-api-forward: Janus-Mini(fast), x-krakend: Version 2, x-krakend-completed: false, status_code: 0, tt_stable: 1, x-tt-logid: 2020101016282401012912820402046358, bd-tt-error-code: 0, rip: api5-normal-c-lq.amemv.com, vary: Accept-Encoding, content-encoding: br, tt-idc-switch: 10000@20200922002, Access-Control-Expose-Headers: tt-idc-switch, server-timing: inner; dur=16, x-tt-trace-host: 010898853b0c09a4ca34d6d8f4cd22c57396c699aa7192df1127231d44bf57a809e59e49601b29abc183ac5112b60ced041844ee800c05b3f613c5978dd294002cac1f8fde960545d364efaa2070189ed4, x-tt-trace-tag: id=3;cdn-cache=miss, x-tt-trace-id: 00-11a015540d977ab7cc82eeec25120468-11a015540d977ab7-01, server-timing: cdn-cache;desc=MISS,edge;dur=0,origin;dur=57, Via: cache17.cn1808[57,0], Timing-Allow-Origin: , EagleId: 6f7b37a516023185045275939e, content-length: 124] 2020-10-10 16:28:25.583 23094-23366/com.ptlife.spcc.starcc E/------mitm 匹配到---------: DefaultHttpRequest(decodeResult: success, version: HTTP/1.1)

monkeyWie commented 3 years ago

跟这个问题一样,可以参考下:https://github.com/monkeyWie/proxyee/issues/97

nsioo commented 3 years ago

跟这个问题一样,可以参考下:#97

谢谢大佬,但是现在使用 FullRequestIntercept 修改 accept-encoding:giz 后,就跟 #100 一样了,响应无法获得

monkeyWie commented 3 years ago

这个不用 FullRequestIntercept ,只是修改请求头

nsioo commented 3 years ago

修改请求头后别人服务器不返回数据了~ 好像有拓展 netty的解码、https://github.com/search?q=Brotli+netty&type=code 我去看看

monkeyWie commented 3 years ago

@nsioo gzip都不支持的服务器吗😅,那个br解码器行的话可以搞个pr来呀

T0DDY commented 3 years ago

@nsioo 你的response header 里面: Content-Type: application/json; charset=utf-8 试试 : Log.e("------mitm res2-----", httpResponse.content().toString(Charset.forName("UTF-8")) ); 可能解决你的问题。 cc @monkeyWie