Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

如何监控http数据流量 #6

Open
Beyond-Chao opened this issue Jan 11, 2018 · 3 comments
Open

如何监控http数据流量 #6

Beyond-Chao opened this issue Jan 11, 2018 · 3 comments

Comments

@Beyond-Chao
Copy link

类似Chrome 查看每次请求的size,或者像Charles抓取每个请求和响应的大小

@zhongwuzw
Copy link
Owner

如果需要每一个请求响应的大小,可以使用NSURLProtocol来拦截进行处理即可,本项目暂时没有做这个。

@Beyond-Chao
Copy link
Author

想请教一个问题,NSURLSession 获取到 response data 大小应该是解压(如何服务端开启了gzip)之后的数据,这样统计的流量是不是不准确了? 想知道这个解压缩操作发生在哪个层,CFNetwork 还是? 谢谢

@zhongwuzw
Copy link
Owner

Gzip传输在URL Loading System会自动处理,Accept-Encoding: gzip头会自动被加上,如果服务器支持gzip传输,那么传输内容将使用gzip进行传输,NSURLResponse响应头中的Content-Lengthgzip压缩后的大小,但是当我们拿到Data时,已经是解压后的数据了,我认为是在CFNetwork层被解压了。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants