Add HTTPTimeout variable to http.go.

This lets users of this library override the default internal timeout for HTTP requests issued by the library. The default is 10 seconds.
This commit is contained in:
xenolf 2016-05-19 18:51:47 +02:00
parent 1389afd8d8
commit 9e0c21c439

View file

@ -14,8 +14,11 @@ import (
// UserAgent (if non-empty) will be tacked onto the User-Agent string in requests. // UserAgent (if non-empty) will be tacked onto the User-Agent string in requests.
var UserAgent string var UserAgent string
// HTTPTimeout is used to override the default HTTP timeout of 10 seconds.
var HTTPTimeout = 10 * time.Second
// defaultClient is an HTTP client with a reasonable timeout value. // defaultClient is an HTTP client with a reasonable timeout value.
var defaultClient = http.Client{Timeout: 10 * time.Second} var defaultClient = http.Client{Timeout: HTTPTimeout}
const ( const (
// defaultGoUserAgent is the Go HTTP package user agent string. Too // defaultGoUserAgent is the Go HTTP package user agent string. Too