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