Marion 5 tahun lalu
induk
melakukan
135ff5b1a5
1 mengubah file dengan 4 tambahan dan 4 penghapusan
  1. 4 4
      utils/http_utils.go

+ 4 - 4
utils/http_utils.go

@@ -243,11 +243,11 @@ func (r *RequestPromise) Call(httpMethod string, targetUri string, data io.Reade
 
 func (r *RequestPromise) initClient() {
 	// http client handle
-	if r.timeout <= 0 {
-		r.timeout = DefaultHttpTimeout // default timeout
-	}
 	if nil == r.client { // create new http client instance
-		r.client = &http.Client{Timeout: r.timeout}
+		r.client = &http.Client{Timeout: DefaultHttpTimeout} // default timeout
+	}
+	if r.timeout < 0 {
+		r.timeout = DefaultHttpTimeout // default timeout
 	}
 	if r.timeout > 0 {
 		r.client.Timeout = r.timeout