@@ -47,12 +47,15 @@ type ClientConfig struct {
47
47
TLSSetting configtls.ClientConfig `mapstructure:"tls"`
48
48
49
49
// ReadBufferSize for HTTP client. See http.Transport.ReadBufferSize.
50
+ // Default is 0.
50
51
ReadBufferSize int `mapstructure:"read_buffer_size"`
51
52
52
53
// WriteBufferSize for HTTP client. See http.Transport.WriteBufferSize.
54
+ // Default is 0.
53
55
WriteBufferSize int `mapstructure:"write_buffer_size"`
54
56
55
57
// Timeout parameter configures `http.Client.Timeout`.
58
+ // Default is 0 (unlimited).
56
59
Timeout time.Duration `mapstructure:"timeout"`
57
60
58
61
// Additional headers attached to each HTTP request sent by the client.
@@ -67,20 +70,20 @@ type ClientConfig struct {
67
70
Compression configcompression.Type `mapstructure:"compression"`
68
71
69
72
// MaxIdleConns is used to set a limit to the maximum idle HTTP connections the client can keep open.
70
- // There's an already set value, and we want to override it only if an explicit value provided
73
+ // By default, it is set to 100.
71
74
MaxIdleConns * int `mapstructure:"max_idle_conns"`
72
75
73
76
// MaxIdleConnsPerHost is used to set a limit to the maximum idle HTTP connections the host can keep open.
74
- // There's an already set value, and we want to override it only if an explicit value provided
77
+ // By default, it is set to [http.DefaultTransport.MaxIdleConnsPerHost].
75
78
MaxIdleConnsPerHost * int `mapstructure:"max_idle_conns_per_host"`
76
79
77
80
// MaxConnsPerHost limits the total number of connections per host, including connections in the dialing,
78
81
// active, and idle states.
79
- // There's an already set value, and we want to override it only if an explicit value provided
82
+ // By default, it is set to [http.DefaultTransport.MaxConnsPerHost].
80
83
MaxConnsPerHost * int `mapstructure:"max_conns_per_host"`
81
84
82
85
// IdleConnTimeout is the maximum amount of time a connection will remain open before closing itself.
83
- // There's an already set value, and we want to override it only if an explicit value provided
86
+ // By default, it is set to [http.DefaultTransport.IdleConnTimeout]
84
87
IdleConnTimeout * time.Duration `mapstructure:"idle_conn_timeout"`
85
88
86
89
// DisableKeepAlives, if true, disables HTTP keep-alives and will only use the connection to the server
@@ -111,17 +114,21 @@ type CookiesConfig struct {
111
114
}
112
115
113
116
// NewDefaultClientConfig returns ClientConfig type object with
114
- // the default values of 'MaxIdleConns' and 'IdleConnTimeout'.
117
+ // the default values of 'MaxIdleConns' and 'IdleConnTimeout', as well as [http.DefaultTransport] values .
115
118
// Other config options are not added as they are initialized with 'zero value' by GoLang as default.
116
119
// We encourage to use this function to create an object of ClientConfig.
117
120
func NewDefaultClientConfig () ClientConfig {
118
121
// The default values are taken from the values of 'DefaultTransport' of 'http' package.
119
- maxIdleConns := 100
120
- idleConnTimeout := 90 * time .Second
122
+ defaultTransport := http .DefaultTransport .(* http.Transport )
121
123
122
124
return ClientConfig {
123
- MaxIdleConns : & maxIdleConns ,
124
- IdleConnTimeout : & idleConnTimeout ,
125
+ ReadBufferSize : defaultTransport .ReadBufferSize ,
126
+ WriteBufferSize : defaultTransport .WriteBufferSize ,
127
+ Headers : map [string ]configopaque.String {},
128
+ MaxIdleConns : & defaultTransport .MaxIdleConns ,
129
+ MaxIdleConnsPerHost : & defaultTransport .MaxIdleConnsPerHost ,
130
+ MaxConnsPerHost : & defaultTransport .MaxConnsPerHost ,
131
+ IdleConnTimeout : & defaultTransport .IdleConnTimeout ,
125
132
}
126
133
}
127
134
0 commit comments