/
githubmirror
/
grafana
Обзор
Документация
Войти
/
githubmirror
/
grafana
Код
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
pkg/util/httpclient/client.go
36 строк
1022 B
beejeebus
Replace usage of http.DefaultClient and http.DefaultTransport (#104135)
09 май 2025, 20:26
Не верифицирован
09 май 2025, 20:26
8f79e48
Код
Авторство
О чём код?
package httpclient import ( "context" "net" "net/http" "time" ) // New creates a new http.Client. func New() *http.Client { return &http.Client{ Transport: NewHTTPTransport(), } } // NewHTTPTransport returns a new HTTP Transport, based off the definition in // the stdlib http.DefaultTransport. It's not a clone, because that would return // any mutations of http.DefaultTransport from other code at the time of the call. // Any plugin that needs a default http transport should use this function. func NewHTTPTransport() http.RoundTripper { return &http.Transport{ Proxy: http.ProxyFromEnvironment, DialContext: func(dialer *net.Dialer) func(context.Context, string, string) (net.Conn, error) { return dialer.DialContext }(&net.Dialer{ Timeout: 30 * time.Second, KeepAlive: 30 * time.Second, }), ForceAttemptHTTP2: true, MaxIdleConns: 100, IdleConnTimeout: 90 * time.Second, TLSHandshakeTimeout: 10 * time.Second, ExpectContinueTimeout: 1 * time.Second, } }