...

Source file src/github.com/go-resty/resty/v2/transport112.go

Documentation: github.com/go-resty/resty/v2

     1  // +build !go1.13
     2  
     3  // Copyright (c) 2015-2021 Jeevanandam M (jeeva@myjeeva.com), All rights reserved.
     4  // resty source code and usage is governed by a MIT style
     5  // license that can be found in the LICENSE file.
     6  
     7  package resty
     8  
     9  import (
    10  	"net"
    11  	"net/http"
    12  	"runtime"
    13  	"time"
    14  )
    15  
    16  func createTransport(localAddr net.Addr) *http.Transport {
    17  	dialer := &net.Dialer{
    18  		Timeout:   30 * time.Second,
    19  		KeepAlive: 30 * time.Second,
    20  		DualStack: true,
    21  	}
    22  	if localAddr != nil {
    23  		dialer.LocalAddr = localAddr
    24  	}
    25  	return &http.Transport{
    26  		Proxy:                 http.ProxyFromEnvironment,
    27  		DialContext:           dialer.DialContext,
    28  		MaxIdleConns:          100,
    29  		IdleConnTimeout:       90 * time.Second,
    30  		TLSHandshakeTimeout:   10 * time.Second,
    31  		ExpectContinueTimeout: 1 * time.Second,
    32  		MaxIdleConnsPerHost:   runtime.GOMAXPROCS(0) + 1,
    33  	}
    34  }
    35  

View as plain text