-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
frame/g: issue g.client will change the header parameters #3758
Comments
// SetHeaderMap sets custom HTTP headers with map. 官方库里面的这个方法能不能修改,或者新增一个方法,m map[string]string -> m map[string][]string |
暂不支持自定义设置,可以用标准库可以解决
|
Custom settings are not supported yet and can be solved using the standard library.
|
package main
import (
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/net/gclient"
"net/http"
)
func main() {
c := g.Client()
c.Use(func(c *gclient.Client, r *http.Request) (resp *gclient.Response, err error) {
// 注意这里不要使用r.Header.Set方法设置Header,会被标准化转换为规范的Header Key
r.Header["userid"] = []string{"10000"}
resp, err = c.Next(r)
return resp, err
})
} |
@wisonlau @hailaz Hello everyone,
package main
import (
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/net/gclient"
"net/http"
)
func main() {
c := g.Client()
c.Use(func(c *gclient.Client, r *http.Request) (resp *gclient.Response, err error) {
// Be careful not to use the r.Header.Set method to set the Header here. It will be standardized and converted into a standard Header Key.
r.Header["userid"] = []string{"10000"}
resp, err = c.Next(r)
return resp, err
})
} |
Go version
go version go1.23.0 darwin/amd64
GoFrame version
v2.7.2
Can this bug be reproduced with the latest release?
Option Yes
What did you do?
What did you see happen?
+---------------------------------------------+
| REQUEST |
+---------------------------------------------+
POST /apiServer/v1/sms/sendMessageOne HTTP/1.1
Host: factor.dcdun.com
User-Agent: GClient v2.7.2 at wisonlaudeMacBook-Pro.local
Content-Length: 141
Content-Type: application/json
Sign: 3317557c2b5bac9c9e08d54a739481e0
Timestamp: 1725549656
Traceparent: 00-a0e2b2404562f217bb0c8811ecc05b71-fd3756d6f43405f6-01
Userid: 46569
Accept-Encoding: gzip
{"messageList":[{"content":"【xxx】验证码808207,您正在进行身份验证,不要告诉别人哦!","phone":"123456"}]}
+---------------------------------------------+
| RESPONSE |
+---------------------------------------------+
HTTP/1.1 200
Connection: close
Transfer-Encoding: chunked
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Content-Type: application/json
Date: Thu, 05 Sep 2024 15:20:56 GMT
Eagleid: 716c4b2c17255496569171587e
Expires: 0
Pragma: no-cache
Server: Tengine
Set-Cookie: sl-session=vCR3TNgd22YylisTR4Mlzw==; Path=/; Max-Age=86400; HttpOnly
Timing-Allow-Origin: *
Vary: Origin
Vary: Access-Control-Request-Method
Vary: Access-Control-Request-Headers
Via: ens-cache5.l2em21-5[18,0], cache24.cn4594[44,0]
X-Content-Type-Options: nosniff
X-Xss-Protection: 0
{"code":500,"msg":"requestHeader中timestamp已过期"}
What did you expect to see?
有些第三方网站只支持头部首字母小写的参数,goframe的工具会把我的参数名字转成首字母大写,比如:timestamp这个参数,这个有什么临时的解决方案救急.
The text was updated successfully, but these errors were encountered: