Browse Source

Merge branch 'master' of http://git.shengws.com/csx/gdyb

csx 3 years ago
parent
commit
fd5cd461d8
1 changed files with 5 additions and 5 deletions
  1. 5 5
      utils/csbhttp/httpcaller.go

+ 5 - 5
utils/csbhttp/httpcaller.go View File

@@ -214,7 +214,7 @@ func Invoke(params HttpParams) (str string, rtnHeaders map[string][]string, hcEr
214 214
 	}
215 215
 
216 216
 	reqUrl := params.requestUrl
217
-	defaultContentType := "application/x-www-form-urlencoded"
217
+	//defaultContentType := "application/x-www-form-urlencoded"
218 218
 	fmt.Println("打印开始")
219 219
 	fmt.Println(params.ct.jsonBody)
220 220
 	fmt.Println(reqUrl)
@@ -227,11 +227,11 @@ func Invoke(params HttpParams) (str string, rtnHeaders map[string][]string, hcEr
227 227
 		//	return str, rtnHeaders, &HttpCallerException{Message: "failed to bad content type json string", CauseErr: err}
228 228
 		//}
229 229
 		reqStr = params.ct.jsonBody
230
-		defaultContentType = params.ct.contentType
230
+		//defaultContentType = "application/json;charset=UTF-8"
231 231
 		reqUrl = appendParams(reqUrl, data.Encode())
232 232
 	} else if params.ct.bytesBody != nil {
233 233
 		reqStr = string(params.ct.bytesBody)
234
-		defaultContentType = params.ct.contentType
234
+		//defaultContentType = params.ct.contentType
235 235
 		reqUrl = appendParams(reqUrl, data.Encode())
236 236
 	} else {
237 237
 		reqStr = data.Encode()
@@ -240,7 +240,7 @@ func Invoke(params HttpParams) (str string, rtnHeaders map[string][]string, hcEr
240 240
 	fmt.Println("打印开始1")
241 241
 	fmt.Println(reqStr)
242 242
 
243
-	req, err := http.NewRequest(method, reqUrl, bytes.NewBufferString(reqStr))
243
+	req, err := http.NewRequest(method, reqUrl, bytes.NewReader([]byte(reqStr)))
244 244
 
245 245
 	fmt.Println("打印开始2")
246 246
 	fmt.Println(req)
@@ -260,7 +260,7 @@ func Invoke(params HttpParams) (str string, rtnHeaders map[string][]string, hcEr
260 260
 	signHeaders := signParams(urlParams, params.api, params.version, params.ak, params.sk)
261 261
 	printDebug("signHeaders", signHeaders)
262 262
 
263
-	req.Header.Add("Content-Type", defaultContentType)
263
+	req.Header.Add("Content-Type", "application/json;charset=UTF-8")
264 264
 	if params.headers != nil {
265 265
 		for k, v := range params.headers {
266 266
 			req.Header.Add(k, v)