2019-02-02 16:18:25 +08:00
|
|
|
|
// Copyright 2017 gf Author(https://github.com/gogf/gf). All Rights Reserved.
|
2018-01-11 16:06:42 +08:00
|
|
|
|
//
|
|
|
|
|
// This Source Code Form is subject to the terms of the MIT License.
|
|
|
|
|
// If a copy of the MIT was not distributed with this file,
|
2019-02-02 16:18:25 +08:00
|
|
|
|
// You can obtain one at https://github.com/gogf/gf.
|
2018-01-11 16:06:42 +08:00
|
|
|
|
|
|
|
|
|
package ghttp
|
|
|
|
|
|
2018-09-26 18:44:30 +08:00
|
|
|
|
import (
|
2019-02-02 16:18:25 +08:00
|
|
|
|
"github.com/gogf/gf/g/encoding/gurl"
|
2018-09-26 18:44:30 +08:00
|
|
|
|
"strings"
|
|
|
|
|
)
|
2018-01-11 16:06:42 +08:00
|
|
|
|
|
|
|
|
|
// 构建请求参数,将参数进行urlencode编码
|
|
|
|
|
func BuildParams(params map[string]string) string {
|
|
|
|
|
var s string
|
|
|
|
|
for k, v := range params {
|
2018-06-19 10:03:44 +08:00
|
|
|
|
if len(s) > 0 {
|
|
|
|
|
s += "&"
|
|
|
|
|
}
|
2018-09-26 18:44:30 +08:00
|
|
|
|
if len(v) > 6 && strings.Compare(v[0 : 6], "@file:") == 0 {
|
|
|
|
|
s += k + "=" + v
|
|
|
|
|
} else {
|
|
|
|
|
s += k + "=" + gurl.Encode(v)
|
|
|
|
|
}
|
2018-01-11 16:06:42 +08:00
|
|
|
|
}
|
|
|
|
|
return s
|
|
|
|
|
}
|