- fk. Request.Close = true for weixin api.
This commit is contained in:
@@ -4,7 +4,6 @@ import (
|
||||
"errors"
|
||||
"net"
|
||||
"net/http"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/fatih/structs"
|
||||
@@ -73,19 +72,11 @@ func init() {
|
||||
structs.DefaultTagName = "json"
|
||||
}
|
||||
|
||||
func AccessPlatformAPIWithRetry(client *http.Client, method, requestURL, body string, header http.Header, config *APIConfig, handleResponse func(response *http.Response) (string, error)) error {
|
||||
func AccessPlatformAPIWithRetry(client *http.Client, handleRequest func() *http.Request, config *APIConfig, handleResponse func(response *http.Response) (string, error)) error {
|
||||
exceedLimitRetryCount := 0
|
||||
recoverableErrorRetryCount := 0
|
||||
var request *http.Request
|
||||
for {
|
||||
if body != "" {
|
||||
request, _ = http.NewRequest(method, requestURL, strings.NewReader(body))
|
||||
} else {
|
||||
request, _ = http.NewRequest(method, requestURL, nil)
|
||||
}
|
||||
if header != nil {
|
||||
request.Header = header
|
||||
}
|
||||
request := handleRequest()
|
||||
response, err := client.Do(request)
|
||||
if err != nil {
|
||||
baseapi.SugarLogger.Debugf("AccessPlatformAPIWithRetry client.Get return err:%v", err)
|
||||
|
||||
Reference in New Issue
Block a user