把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 {
|
if body.IOBody == nil {
|
||||||
req, err = http.NewRequest(ver, rawurl, nil)
|
req, err = http.NewRequest(ver, rawurl, nil)
|
||||||
} else {
|
} else {
|
||||||
contentType = TypeURLENCODED
|
|
||||||
var bodybuf *bytes.Buffer
|
var bodybuf *bytes.Buffer
|
||||||
switch body.IOBody.(type) {
|
switch body.IOBody.(type) {
|
||||||
case []byte:
|
case []byte:
|
||||||
@ -33,7 +32,17 @@ func buildBodyRequest(ver, rawurl string, body *Body) *http.Request {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if body.ContentType != "" {
|
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 != "" {
|
if contentType != "" {
|
||||||
|
@ -50,6 +50,8 @@ const (
|
|||||||
TypeURLENCODED = "application/x-www-form-urlencoded"
|
TypeURLENCODED = "application/x-www-form-urlencoded"
|
||||||
// TypeForm PostForm类型
|
// TypeForm PostForm类型
|
||||||
TypeForm = TypeURLENCODED
|
TypeForm = TypeURLENCODED
|
||||||
|
// TypeContentEmpty 没有Form的类型 Content
|
||||||
|
TypeContentEmpty = "ContentEmpty"
|
||||||
// TypeFormData 类型
|
// TypeFormData 类型
|
||||||
TypeFormData = "multipart/form-data"
|
TypeFormData = "multipart/form-data"
|
||||||
// HeaderKeyHost Host
|
// HeaderKeyHost Host
|
||||||
|
Loading…
x
Reference in New Issue
Block a user