edge proxy support + updated readme

This commit is contained in:
stefanodvx 2025-04-20 01:00:50 +02:00
parent 8d57b97b0f
commit 6f5e792b01
5 changed files with 222 additions and 86 deletions

View file

@ -10,34 +10,28 @@ import (
var (
httpSession *http.Client
httpSessionOnce sync.Once
baseTransport = &http.Transport{
Proxy: http.ProxyFromEnvironment,
DialContext: (&net.Dialer{
Timeout: 30 * time.Second,
KeepAlive: 30 * time.Second,
}).DialContext,
ForceAttemptHTTP2: true,
MaxIdleConns: 100,
IdleConnTimeout: 90 * time.Second,
TLSHandshakeTimeout: 5 * time.Second,
ExpectContinueTimeout: 1 * time.Second,
MaxIdleConnsPerHost: 100,
MaxConnsPerHost: 100,
ResponseHeaderTimeout: 10 * time.Second,
DisableCompression: false,
}
)
func GetHTTPSession() *http.Client {
httpSessionOnce.Do(func() {
transport := &http.Transport{
Proxy: http.ProxyFromEnvironment,
DialContext: (&net.Dialer{
Timeout: 30 * time.Second,
KeepAlive: 30 * time.Second,
}).DialContext,
ForceAttemptHTTP2: true,
MaxIdleConns: 100,
IdleConnTimeout: 90 * time.Second,
TLSHandshakeTimeout: 5 * time.Second,
ExpectContinueTimeout: 1 * time.Second,
MaxIdleConnsPerHost: 100,
MaxConnsPerHost: 100,
ResponseHeaderTimeout: 10 * time.Second,
DisableCompression: false,
}
httpSession = &http.Client{
Transport: transport,
Transport: baseTransport,
Timeout: 60 * time.Second,
}
})