This commit is contained in:
bxd
2023-12-08 13:30:00 +08:00
parent 8e4ddfd0cc
commit 42df548958
3 changed files with 45 additions and 24 deletions

View File

@@ -1,6 +1,7 @@
package requests
import (
"errors"
"net/http"
)
@@ -20,10 +21,16 @@ func (obj *RequestOption) initHeaders() (http.Header, error) {
case http.Header:
return headers.Clone(), nil
default:
_, dataMap, _, err := obj.newBody(headers, mapType)
if dataMap == nil || err != nil {
body, dataMap, _, err := obj.newBody(headers, mapType)
if err != nil {
return nil, err
}
if body != nil {
return nil, errors.New("headers type error")
}
if dataMap == nil {
return nil, nil
}
head, order := dataMap.parseHeaders()
obj.OrderHeaders = order
return head, err