Skip to content

Commit 337dd5a

Browse files
committed
feat: move http timeout literals into one variable
1 parent e9b4d16 commit 337dd5a

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

v2/validator.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ func checkHeader(response *urlValidationResponse, header http.Header) {
189189

190190
func fetchURL(validationResponse *urlValidationResponse, url *url.URL, skipVerify bool) (http.Header, string, error) {
191191
dialer := net.Dialer{}
192+
httpTimeout := 10 * time.Second
192193
trv6 := &http.Transport{
193194
TLSClientConfig: &tls.Config{InsecureSkipVerify: skipVerify},
194195
DialContext: func(ctx context.Context, network, addr string) (net.Conn, error) {
@@ -206,17 +207,17 @@ func fetchURL(validationResponse *urlValidationResponse, url *url.URL, skipVerif
206207
}
207208

208209
clientv6 := http.Client{
209-
Timeout: time.Second * 10,
210+
Timeout: httpTimeout,
210211
Transport: trv6,
211212
}
212213
defer clientv6.CloseIdleConnections()
213214
clientv4 := http.Client{
214-
Timeout: time.Second * 10,
215+
Timeout: httpTimeout,
215216
Transport: trv4,
216217
}
217218
defer clientv4.CloseIdleConnections()
218219
client := http.Client{
219-
Timeout: time.Second * 10,
220+
Timeout: httpTimeout,
220221
CheckRedirect: func(req *http.Request, via []*http.Request) error {
221222
if req.URL.Scheme == "https" {
222223
validationResponse.HTTPSForward = true

0 commit comments

Comments
 (0)