Make the default timout 5 minutes when timeout is 0 (#2667)

This commit is contained in:
The Magician 2018-12-17 12:53:06 -08:00 committed by Nathan McKinley
parent 6c6b1f62d9
commit 5b075c1eca

View File

@ -33,7 +33,7 @@ func isEmptyValue(v reflect.Value) bool {
} }
func sendRequest(config *Config, method, rawurl string, body map[string]interface{}) (map[string]interface{}, error) { func sendRequest(config *Config, method, rawurl string, body map[string]interface{}) (map[string]interface{}, error) {
return sendRequestWithTimeout(config, method, rawurl, body, 0) return sendRequestWithTimeout(config, method, rawurl, body, 5*time.Minute)
} }
func sendRequestWithTimeout(config *Config, method, rawurl string, body map[string]interface{}, timeout time.Duration) (map[string]interface{}, error) { func sendRequestWithTimeout(config *Config, method, rawurl string, body map[string]interface{}, timeout time.Duration) (map[string]interface{}, error) {
@ -41,6 +41,10 @@ func sendRequestWithTimeout(config *Config, method, rawurl string, body map[stri
reqHeaders.Set("User-Agent", config.userAgent) reqHeaders.Set("User-Agent", config.userAgent)
reqHeaders.Set("Content-Type", "application/json") reqHeaders.Set("Content-Type", "application/json")
if timeout == 0 {
timeout = time.Duration(1) * time.Hour
}
var res *http.Response var res *http.Response
err := retryTimeDuration( err := retryTimeDuration(
func() error { func() error {