Skip to content

Commit

Permalink
修复url.ParseParams和url.ParseValues解析问题
Browse files Browse the repository at this point in the history
  • Loading branch information
wangluozhe committed Feb 21, 2023
1 parent 0de5aeb commit 975301c
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions sessions.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func merge_setting(request_setting, session_setting interface{}) interface{} {
return merged_setting
}
for key, _ := range *requestd_setting {
merged_setting.Set(key,(*requestd_setting)[key][0])
merged_setting.Set(key, (*requestd_setting)[key][0])
}
return merged_setting
case []string:
Expand Down Expand Up @@ -361,7 +361,7 @@ func (s *Session) Send(preq *models.PrepareRequest, req *url.Request) (*models.R

u, _ := url2.Parse(preq.Url)
// 设置有序请求头
if req.Headers != nil{
if req.Headers != nil {
if (*req.Headers)[http.HeaderOrderKey] != nil {
(*preq.Headers)[http.HeaderOrderKey] = (*req.Headers)[http.HeaderOrderKey]
}
Expand Down
6 changes: 3 additions & 3 deletions url/Params.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ func ParseParams(params string) *Params {
return p
}
for _, l := range strings.Split(params, "&") {
value := strings.Split(l, "=")
if len(value) == 2{
value := strings.SplitN(l, "=", 2)
if len(value) == 2 {
p.Add(value[0], value[1])
}
}
Expand All @@ -44,7 +44,7 @@ type Params struct {
// 设置Params参数
func (p *Params) Set(key, value string) {
pm := map[string][]string{
key: []string{value,},
key: []string{value},
}
index := SearchStrings(p.indexKey, key)
if len(p.indexKey) == 0 || index == -1 {
Expand Down
2 changes: 1 addition & 1 deletion url/Values.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ func ParseValues(params string) *Values {
return p
}
for _, l := range strings.Split(params, "&") {
value := strings.Split(l, "=")
value := strings.SplitN(l, "=", 2)
if len(value) == 2{
p.Add(value[0], value[1])
}
Expand Down
2 changes: 1 addition & 1 deletion version.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ package requests

const (
NAME = "golang-requests" // 名称
VERSION = "1.0.4" // 当前版本
VERSION = "1.0.41" // 当前版本
USER_AGENT = NAME + VERSION // UA
)

0 comments on commit 975301c

Please sign in to comment.