修复一波不兼容逻辑
This commit is contained in:
@ -8,8 +8,9 @@
|
||||
package validate
|
||||
|
||||
import (
|
||||
"git.zhangdeman.cn/zhangdeman/network/httpclient/define"
|
||||
"fmt"
|
||||
"git.zhangdeman.cn/zhangdeman/consts"
|
||||
"git.zhangdeman.cn/zhangdeman/network/httpclient/define"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"strings"
|
||||
@ -49,18 +50,23 @@ func (rc *requestConfig) initDefaultConfig(reqConfig *define.Request) {
|
||||
}
|
||||
}
|
||||
if nil == reqConfig.Header {
|
||||
reqConfig.Header = map[string]string{}
|
||||
reqConfig.Header = map[string]any{}
|
||||
}
|
||||
if len(reqConfig.ContentType) > 0 {
|
||||
reqConfig.Header[consts.HeaderKeyContentType.String()] = reqConfig.ContentType
|
||||
} else {
|
||||
if len(reqConfig.Header[consts.HeaderKeyContentType.String()]) == 0 {
|
||||
if val, exist := reqConfig.Header[consts.HeaderKeyContentType.String()]; exist {
|
||||
if val == nil || fmt.Sprintf("%v", val) == "" {
|
||||
// 没配置Content-Type, 默认JSON
|
||||
reqConfig.Header[consts.HeaderKeyContentType.String()] = consts.MimeTypeJson
|
||||
}
|
||||
} else {
|
||||
// 没配置Content-Type, 默认JSON
|
||||
reqConfig.Header[consts.HeaderKeyContentType.String()] = consts.MimeTypeJson
|
||||
}
|
||||
}
|
||||
if nil == reqConfig.Cookie {
|
||||
reqConfig.Cookie = map[string]string{}
|
||||
reqConfig.Cookie = map[string]any{}
|
||||
}
|
||||
if reqConfig.ConnectTimeout <= 0 {
|
||||
reqConfig.ConnectTimeout = define.DefaultConnectTimeout
|
||||
|
Reference in New Issue
Block a user