1
0
mirror of https://github.com/restic/restic.git synced 2024-07-04 09:00:54 +02:00
restic/internal/backend/http_transport.go

31 lines
690 B
Go
Raw Normal View History

2017-05-01 19:30:52 +02:00
package backend
import (
"net"
"net/http"
"time"
2017-07-23 14:21:03 +02:00
"github.com/restic/restic/internal/debug"
2017-05-01 19:30:52 +02:00
)
// Transport returns a new http.RoundTripper with default settings applied.
func Transport() http.RoundTripper {
// copied from net/http
tr := &http.Transport{
Proxy: http.ProxyFromEnvironment,
DialContext: (&net.Dialer{
Timeout: 30 * time.Second,
KeepAlive: 30 * time.Second,
DualStack: true,
}).DialContext,
MaxIdleConns: 100,
MaxIdleConnsPerHost: 100,
2017-05-01 19:30:52 +02:00
IdleConnTimeout: 90 * time.Second,
TLSHandshakeTimeout: 10 * time.Second,
ExpectContinueTimeout: 1 * time.Second,
}
// wrap in the debug round tripper
return debug.RoundTripper(tr)
}