diff --git a/cmd/mitmproxy/main.go b/cmd/mitmproxy/main.go index 1350928..f2f96ea 100644 --- a/cmd/mitmproxy/main.go +++ b/cmd/mitmproxy/main.go @@ -16,7 +16,8 @@ func main() { }) opts := &proxy.Options{ - Addr: ":9080", + Addr: ":9080", + StreamLargeBodies: 1024 * 1024 * 5, } p, err := proxy.NewProxy(opts) diff --git a/proxy/proxy.go b/proxy/proxy.go index 2ee1e07..2700467 100644 --- a/proxy/proxy.go +++ b/proxy/proxy.go @@ -73,14 +73,15 @@ func transfer(log *_log.Entry, a, b io.ReadWriter) { } type Options struct { - Addr string + Addr string + StreamLargeBodies int64 } type Proxy struct { Server *http.Server Client *http.Client Mitm Mitm - StreamLargeBodies int64 + StreamLargeBodies int64 // 当请求或响应体大于此字节时,转为 stream 模式 Addons []flow.Addon } @@ -344,7 +345,11 @@ func NewProxy(opts *Options) (*Proxy, error) { proxy.Mitm = mitm - proxy.StreamLargeBodies = 1024 * 1024 * 5 // 5mb + if opts.StreamLargeBodies > 0 { + proxy.StreamLargeBodies = opts.StreamLargeBodies + } else { + proxy.StreamLargeBodies = 1024 * 1024 * 5 // default: 5mb + } proxy.Addons = make([]flow.Addon, 0) proxy.AddAddon(&flow.LogAddon{})