修改请求方式
This commit is contained in:
parent
6f3495f0f5
commit
4e915d02ef
|
|
@ -301,7 +301,6 @@ func SyncDataFromMasterShellReq3(url string, data proto.SyncUserShellResp) ([]pr
|
|||
}
|
||||
|
||||
func DoPostRequestJSON(url string, jsonData []byte, headers map[string]string) (error, []byte) {
|
||||
httpClient := &http.Client{}
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
fmt.Println("SyncDataFromMasterReq2 error:", r)
|
||||
|
|
@ -320,12 +319,12 @@ func DoPostRequestJSON(url string, jsonData []byte, headers map[string]string) (
|
|||
req.Header.Set(k, v)
|
||||
}
|
||||
//传输数据
|
||||
if httpClient == nil {
|
||||
if client == nil {
|
||||
InitReqClient()
|
||||
httpClient = client
|
||||
client = client
|
||||
}
|
||||
//获取数据
|
||||
resp, err := httpClient.Do(req)
|
||||
resp, err := client.Do(req)
|
||||
if err != nil {
|
||||
return err, nil
|
||||
}
|
||||
|
|
@ -339,7 +338,6 @@ func DoPostRequestJSON(url string, jsonData []byte, headers map[string]string) (
|
|||
}
|
||||
|
||||
func DoPostRequestForm(url string, jsonData []byte, headers map[string]string) (error, []byte) {
|
||||
httpClient := &http.Client{}
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
fmt.Println("SyncDataFromMasterReq2 error:", r)
|
||||
|
|
@ -399,7 +397,7 @@ func DoPostRequestForm(url string, jsonData []byte, headers map[string]string) (
|
|||
}
|
||||
|
||||
// 发送请求
|
||||
resp, err := httpClient.Do(req)
|
||||
resp, err := client.Do(req)
|
||||
if err != nil {
|
||||
return err, nil
|
||||
}
|
||||
|
|
@ -415,7 +413,6 @@ func DoPostRequestForm(url string, jsonData []byte, headers map[string]string) (
|
|||
}
|
||||
|
||||
func DoPostRequestFormUrlEncoded(url_ string, jsonData []byte, headers map[string]string) (error, []byte) {
|
||||
httpClient := &http.Client{}
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
log.Println("SyncDataFromMasterReq2 error:", r)
|
||||
|
|
@ -466,7 +463,7 @@ func DoPostRequestFormUrlEncoded(url_ string, jsonData []byte, headers map[strin
|
|||
}
|
||||
|
||||
// 发送请求
|
||||
resp, err := httpClient.Do(req)
|
||||
resp, err := client.Do(req)
|
||||
if err != nil {
|
||||
return err, nil
|
||||
}
|
||||
|
|
@ -482,7 +479,6 @@ func DoPostRequestFormUrlEncoded(url_ string, jsonData []byte, headers map[strin
|
|||
}
|
||||
|
||||
func DoGetRequest(url string, headers map[string]string) (error, []byte) {
|
||||
httpClient := &http.Client{}
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
fmt.Println("SyncDataFromMasterReq2 error:", r)
|
||||
|
|
@ -500,12 +496,12 @@ func DoGetRequest(url string, headers map[string]string) (error, []byte) {
|
|||
req.Header.Set(k, v)
|
||||
}
|
||||
//传输数据
|
||||
if httpClient == nil {
|
||||
if client == nil {
|
||||
InitReqClient()
|
||||
httpClient = client
|
||||
client = client
|
||||
}
|
||||
//获取数据
|
||||
resp, err := httpClient.Do(req)
|
||||
resp, err := client.Do(req)
|
||||
if err != nil {
|
||||
return err, nil
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue