close socket when http client request over

To avoid a large number of  TIME_WAIT in server which http client talk with
This commit is contained in:
redfoxli 2016-04-22 13:54:55 +08:00
parent e89f562396
commit b36afadbdc
1 changed files with 4 additions and 3 deletions

View File

@ -409,9 +409,10 @@ func (b *BeegoHTTPRequest) DoRequest() (*http.Response, error) {
if trans == nil {
// create default transport
trans = &http.Transport{
TLSClientConfig: b.setting.TLSClientConfig,
Proxy: b.setting.Proxy,
Dial: TimeoutDialer(b.setting.ConnectTimeout, b.setting.ReadWriteTimeout),
TLSClientConfig: b.setting.TLSClientConfig,
Proxy: b.setting.Proxy,
Dial: TimeoutDialer(b.setting.ConnectTimeout, b.setting.ReadWriteTimeout),
MaxIdleConnsPerHost: -1,
}
} else {
// if b.transport is *http.Transport then set the settings.