- fix retry bug (request can not be reused).

This commit is contained in:
gazebo
2018-08-15 22:06:57 +08:00
parent fa83668d82
commit 47e1b3989d
11 changed files with 65 additions and 40 deletions

View File

@@ -143,9 +143,9 @@ func (a *API) AccessAPI(apiStr string, jdParams map[string]interface{}) (retVal
params["timestamp"] = utils.GetCurTimeStr()
sign := a.signParams(params)
params[signKey] = sign
request, _ := http.NewRequest(http.MethodGet, utils.GenerateGetURL(prodURL, apiStr, params), nil)
// request, _ := http.NewRequest(http.MethodGet, utils.GenerateGetURL(prodURL, apiStr, params), nil)
//request.Close = true //todo 为了性能考虑
err = platformapi.AccessPlatformAPIWithRetry(a.client, request, a.config, func(response *http.Response) (errLevel string, err error) {
err = platformapi.AccessPlatformAPIWithRetry(a.client, http.MethodGet, utils.GenerateGetURL(prodURL, apiStr, params), "", nil, a.config, func(response *http.Response) (errLevel string, err error) {
jsonResult1, err := utils.HTTPResponse2Json(response)
if err != nil {
return platformapi.ErrLevelGeneralFail, platformapi.ErrResponseDataFormatWrong

View File

@@ -225,7 +225,7 @@ func TestCallbackMsgPlayback(t *testing.T) {
},
}
for _, v := range playbackData {
_, err := utils.SendFakeRequest("POST", v[1], v[0], "")
_, err := utils.SendFakeRequest(http.MethodPost, v[1], v[0], "")
if err != nil {
t.Fatal(err)
}