improve parameter parsing feature for ghttp.Request

This commit is contained in:
John
2020-01-01 14:26:00 +08:00
parent fe5d2e5685
commit 9219471f67

View File

@ -95,7 +95,7 @@ func (c *Client) Post(url string, data ...interface{}) (resp *ClientResponse, er
if json.Valid(paramBytes) {
// Auto detecting and setting the post content format: JSON.
req.Header.Set("Content-Type", "application/json")
} else if gregex.IsMatchString(`^\w+=.+`, param) {
} else if gregex.IsMatchString(`^[\w\[\]]+=.+`, param) {
// If the parameters passed like "name=value", it then uses form type.
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
}