把Post 改为默认Form 需要不默认则调用参数TypeContentEmpty
This commit is contained in:
parent
8a0a21fc5e
commit
166fe96265
13
base.go
13
base.go
|
@ -15,7 +15,6 @@ func buildBodyRequest(ver, rawurl string, body *Body) *http.Request {
|
|||
if body.IOBody == nil {
|
||||
req, err = http.NewRequest(ver, rawurl, nil)
|
||||
} else {
|
||||
contentType = TypeURLENCODED
|
||||
var bodybuf *bytes.Buffer
|
||||
switch body.IOBody.(type) {
|
||||
case []byte:
|
||||
|
@ -33,7 +32,17 @@ func buildBodyRequest(ver, rawurl string, body *Body) *http.Request {
|
|||
}
|
||||
|
||||
if body.ContentType != "" {
|
||||
contentType = body.ContentType
|
||||
if body.ContentType == TypeContentEmpty {
|
||||
contentType = ""
|
||||
} else {
|
||||
contentType = body.ContentType
|
||||
}
|
||||
} else {
|
||||
if contentType == "" {
|
||||
if ver == "POST" || ver == "PUT" || ver == "Patch" {
|
||||
contentType = TypeURLENCODED
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if contentType != "" {
|
||||
|
|
|
@ -50,6 +50,8 @@ const (
|
|||
TypeURLENCODED = "application/x-www-form-urlencoded"
|
||||
// TypeForm PostForm类型
|
||||
TypeForm = TypeURLENCODED
|
||||
// TypeContentEmpty 没有Form的类型 Content
|
||||
TypeContentEmpty = "ContentEmpty"
|
||||
// TypeFormData 类型
|
||||
TypeFormData = "multipart/form-data"
|
||||
// HeaderKeyHost Host
|
||||
|
|
Loading…
Reference in New Issue
Block a user