PostForm 与 其他形式的分辨 bug
This commit is contained in:
parent
025f911c0e
commit
8a0a21fc5e
12
base.go
12
base.go
|
@ -10,10 +10,12 @@ import (
|
||||||
func buildBodyRequest(ver, rawurl string, body *Body) *http.Request {
|
func buildBodyRequest(ver, rawurl string, body *Body) *http.Request {
|
||||||
var req *http.Request
|
var req *http.Request
|
||||||
var err error
|
var err error
|
||||||
|
contentType := ""
|
||||||
|
|
||||||
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:
|
||||||
|
@ -30,10 +32,12 @@ func buildBodyRequest(ver, rawurl string, body *Body) *http.Request {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if body.ContentType == "" {
|
if body.ContentType != "" {
|
||||||
req.Header.Set(HeaderKeyContentType, TypeURLENCODED)
|
contentType = body.ContentType
|
||||||
} else {
|
}
|
||||||
req.Header.Set(HeaderKeyContentType, body.ContentType)
|
|
||||||
|
if contentType != "" {
|
||||||
|
req.Header.Set(HeaderKeyContentType, contentType)
|
||||||
}
|
}
|
||||||
|
|
||||||
return req
|
return req
|
||||||
|
|
|
@ -48,6 +48,8 @@ const (
|
||||||
TypeXML = "text/xml"
|
TypeXML = "text/xml"
|
||||||
// TypeURLENCODED 类型
|
// TypeURLENCODED 类型
|
||||||
TypeURLENCODED = "application/x-www-form-urlencoded"
|
TypeURLENCODED = "application/x-www-form-urlencoded"
|
||||||
|
// TypeForm PostForm类型
|
||||||
|
TypeForm = TypeURLENCODED
|
||||||
// TypeFormData 类型
|
// TypeFormData 类型
|
||||||
TypeFormData = "multipart/form-data"
|
TypeFormData = "multipart/form-data"
|
||||||
// HeaderKeyHost Host
|
// HeaderKeyHost Host
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package requests
|
package requests
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
"regexp"
|
"regexp"
|
||||||
|
@ -231,6 +232,7 @@ func mergeMapList(headers ...map[string][]string) map[string][]string {
|
||||||
// setHeaderRequest 设置request的头
|
// setHeaderRequest 设置request的头
|
||||||
func setHeaderRequest(req *http.Request, wf *Workflow) {
|
func setHeaderRequest(req *http.Request, wf *Workflow) {
|
||||||
req.Header = mergeMapList(req.Header, wf.session.Header, wf.Header)
|
req.Header = mergeMapList(req.Header, wf.session.Header, wf.Header)
|
||||||
|
log.Println(wf.Header, wf.session.Header)
|
||||||
}
|
}
|
||||||
|
|
||||||
// setHeaderRequest 设置request的临时Cookie, 永久需要在session上设置cookie
|
// setHeaderRequest 设置request的临时Cookie, 永久需要在session上设置cookie
|
||||||
|
|
Loading…
Reference in New Issue
Block a user