From b3c46a87ac33027436cbf1b95ede475f0c638283 Mon Sep 17 00:00:00 2001 From: Colstuwjx Date: Thu, 5 Jul 2018 19:15:42 +0800 Subject: [PATCH] Fix: correct MaxIdleConnsPerHost value to net/http default 100. --- httplib/httplib.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/httplib/httplib.go b/httplib/httplib.go index 5d82ab33..47464e13 100644 --- a/httplib/httplib.go +++ b/httplib/httplib.go @@ -317,6 +317,7 @@ func (b *BeegoHTTPRequest) Body(data interface{}) *BeegoHTTPRequest { } return b } + // XMLBody adds request raw body encoding by XML. func (b *BeegoHTTPRequest) XMLBody(obj interface{}) (*BeegoHTTPRequest, error) { if b.req.Body == nil && obj != nil { @@ -330,6 +331,7 @@ func (b *BeegoHTTPRequest) XMLBody(obj interface{}) (*BeegoHTTPRequest, error) { } return b, nil } + // JSONBody adds request raw body encoding by JSON. func (b *BeegoHTTPRequest) JSONBody(obj interface{}) (*BeegoHTTPRequest, error) { if b.req.Body == nil && obj != nil { @@ -444,7 +446,7 @@ func (b *BeegoHTTPRequest) DoRequest() (resp *http.Response, err error) { TLSClientConfig: b.setting.TLSClientConfig, Proxy: b.setting.Proxy, Dial: TimeoutDialer(b.setting.ConnectTimeout, b.setting.ReadWriteTimeout), - MaxIdleConnsPerHost: -1, + MaxIdleConnsPerHost: 100, } } else { // if b.transport is *http.Transport then set the settings.