add StreamLargeBodies option

addon-dailer
lqqyt2423 4 years ago
parent c07364b358
commit 573723b61e

@ -17,6 +17,7 @@ func main() {
opts := &proxy.Options{ opts := &proxy.Options{
Addr: ":9080", Addr: ":9080",
StreamLargeBodies: 1024 * 1024 * 5,
} }
p, err := proxy.NewProxy(opts) p, err := proxy.NewProxy(opts)

@ -74,13 +74,14 @@ func transfer(log *_log.Entry, a, b io.ReadWriter) {
type Options struct { type Options struct {
Addr string Addr string
StreamLargeBodies int64
} }
type Proxy struct { type Proxy struct {
Server *http.Server Server *http.Server
Client *http.Client Client *http.Client
Mitm Mitm Mitm Mitm
StreamLargeBodies int64 StreamLargeBodies int64 // 当请求或响应体大于此字节时,转为 stream 模式
Addons []flow.Addon Addons []flow.Addon
} }
@ -344,7 +345,11 @@ func NewProxy(opts *Options) (*Proxy, error) {
proxy.Mitm = mitm 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.Addons = make([]flow.Addon, 0)
proxy.AddAddon(&flow.LogAddon{}) proxy.AddAddon(&flow.LogAddon{})

Loading…
Cancel
Save