测试reqeust

This commit is contained in:
苏尹岚
2020-05-20 17:23:02 +08:00
parent df3217366e
commit 833a1f4cfb
2 changed files with 4 additions and 2 deletions

View File

@@ -21,6 +21,10 @@ func (a *API) AccessStorePage(fullURL string, bizParams map[string]interface{},
if isPost {
request, _ = http.NewRequest(http.MethodPost, fullURL, strings.NewReader(utils.Map2URLValues(bizParams).Encode()))
request.Header.Set("Content-Type", "application/x-www-form-urlencoded")
request.Header.Set("accept", "application/json, text/plain, */*")
request.Header.Set("accept-encoding", "gzip, deflate, br")
request.Header.Set("accept-language", "zh-CN,zh;q=0.9")
request.Header.Set("referer", "https://stores.shop.jd.com/")
} else {
request, _ = http.NewRequest(http.MethodGet, utils.GenerateGetURL(fullURL, "", bizParams), nil)
}

View File

@@ -117,8 +117,6 @@ func AccessPlatformAPIWithRetry(client *http.Client, handleRequest func() *http.
}
trackInfo += ", " + utils.GetUUID()
baseapi.SugarLogger.Debugf("begin AccessPlatformAPIWithRetry:%s do:%s url:%v, request:%s", trackInfo, request.Method, request.URL, getClonedData(request.URL, savedBuf))
fmt.Println("test1", utils.Format4Output(request, false))
fmt.Println("test1", utils.Format4Output(request.Context(), false))
response, err := client.Do(request)
usedMilliSecond := time.Now().Sub(beginTime) / time.Millisecond
baseapi.SugarLogger.Debugf("end AccessPlatformAPIWithRetry:%s do:%s url:%v, usedMilliSecond:%d", trackInfo, request.Method, request.URL, usedMilliSecond)