- fix retry bug (request can not be reused).
This commit is contained in:
@@ -193,10 +193,11 @@ func (a *API) AccessAPI(action string, params map[string]interface{}) (retVal *R
|
||||
params2["version"] = []string{"1.0"}
|
||||
params2[signKey] = []string{a.signParams(params2)}
|
||||
// baseapi.SugarLogger.Debug(params2.Encode())
|
||||
request, _ := http.NewRequest("POST", mtpsAPIURL+"/"+action, strings.NewReader(params2.Encode()))
|
||||
request.Header.Set("Content-Type", "application/x-www-form-urlencoded")
|
||||
// request, _ := http.NewRequest(http.MethodPost, mtpsAPIURL+"/"+action, strings.NewReader(params2.Encode()))
|
||||
header := make(http.Header)
|
||||
header.Set("Content-Type", "application/x-www-form-urlencoded")
|
||||
|
||||
err = platformapi.AccessPlatformAPIWithRetry(a.client, request, a.config, func(response *http.Response) (result string, err error) {
|
||||
err = platformapi.AccessPlatformAPIWithRetry(a.client, http.MethodPost, mtpsAPIURL+"/"+action, params2.Encode(), header, a.config, func(response *http.Response) (result string, err error) {
|
||||
jsonResult1, err := utils.HTTPResponse2Json(response)
|
||||
if err != nil {
|
||||
return platformapi.ErrLevelGeneralFail, platformapi.ErrResponseDataFormatWrong
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package mtpsapi
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"git.rosy.net.cn/baseapi"
|
||||
@@ -33,6 +34,8 @@ func handleError(t *testing.T, err error) {
|
||||
}
|
||||
func TestTest(t *testing.T) {
|
||||
sugarLogger.Debug(utils.GetCurTimeStr())
|
||||
tmpStr := "this is a\u00A0"
|
||||
sugarLogger.Debug(strings.Trim(tmpStr, " \u00A0"))
|
||||
}
|
||||
|
||||
func TestAccessAPI(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user