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

是否能实现请求计数功能 #17

Open
huanying1988 opened this issue Aug 28, 2018 · 1 comment
Open

是否能实现请求计数功能 #17

huanying1988 opened this issue Aug 28, 2018 · 1 comment

Comments

@huanying1988
Copy link

我在尝试使用gomitmproxy的Forward功能,将请求代理至下一级代理,我想在转发的时候做一个计数统计,看一段时间内转发了多少请求。
我发现使用了io.Copy(dst, src)之后,所有请求在两个connection之间直接拷贝转发,根本拦截不到到底发送了多少个请求。有办法可以满足我的技术需求吗?谢谢

@zboya
Copy link
Owner

zboya commented Aug 28, 2018

目前的实现是直接用io.Copy,实现两个tcp连接直接交换数据,你要统计http请求,就必须解析http协议报文,你得自己重新实现Transport,解析connIn的http req(这里可以考虑用https://golang.org/pkg/io/#TeeReader copy一份流来做解析统计),然后写入connOut,再从connOut读取数据写入connIn。解析httpreq, golang相关的接口https://golang.google.cn/pkg/net/http/#ReadRequest

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

No branches or pull requests

2 participants