1
0
mirror of https://github.com/duke-git/lancet.git synced 2026-02-11 08:12:26 +08:00

fix: fix http post to support multipart/form-data header

This commit is contained in:
dudaodong
2022-04-14 11:48:39 +08:00
parent c960841491
commit b4cd0750e4
3 changed files with 33 additions and 2 deletions

View File

@@ -81,10 +81,16 @@ func setHeaderAndQueryAndBody(req *http.Request, reqUrl string, header, queryPar
if err != nil {
return err
}
err = setBodyByte(req, body)
if req.Header.Get("Content-Type") == "multipart/form-data" || req.Header.Get("Content-Type") == "application/x-www-form-urlencoded" {
formData := queryParam.(url.Values)
err = setBodyByte(req, []byte(formData.Encode()))
} else {
err = setBodyByte(req, body)
}
if err != nil {
return err
}
return nil
}