forked from TrueCloudLab/lego
acme/http: saner http client timeouts (#377)
LE is becoming quite popular and it was observed that response time can be around 15s. I've increased this to 30s and added changes recomended here https://blog.cloudflare.com/the-complete-guide-to-golang-net-http-timeouts/
This commit is contained in:
parent
b2aab0377c
commit
147b326cb0
1 changed files with 12 additions and 1 deletions
13
acme/http.go
13
acme/http.go
|
@ -5,6 +5,7 @@ import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
"runtime"
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
|
@ -15,7 +16,17 @@ import (
|
||||||
var UserAgent string
|
var UserAgent string
|
||||||
|
|
||||||
// HTTPClient is an HTTP client with a reasonable timeout value.
|
// HTTPClient is an HTTP client with a reasonable timeout value.
|
||||||
var HTTPClient = http.Client{Timeout: 10 * time.Second}
|
var HTTPClient = http.Client{
|
||||||
|
Transport: &http.Transport{
|
||||||
|
Dial: (&net.Dialer{
|
||||||
|
Timeout: 30 * time.Second,
|
||||||
|
KeepAlive: 30 * time.Second,
|
||||||
|
}).Dial,
|
||||||
|
TLSHandshakeTimeout: 15 * time.Second,
|
||||||
|
ResponseHeaderTimeout: 15 * time.Second,
|
||||||
|
ExpectContinueTimeout: 1 * time.Second,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
// defaultGoUserAgent is the Go HTTP package user agent string. Too
|
// defaultGoUserAgent is the Go HTTP package user agent string. Too
|
||||||
|
|
Loading…
Reference in a new issue