You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
First of all, in the HTTP protocol, the standardized Header Key is capitalized, and the English word connection symbol - is used to connect multiple words.
Secondly, in the gclient package of goframe, the Header is set through the HTTP Header Set method of the standard library. The specific source code is here https://github.com/gogf/gf/blob/183395f/net/gclient/gclient_request.go#L329
Finally, if you really want to customize a unique Header, you can consider using the gclient front-end middleware to implement it. For details, please refer to the document https://goframe.org/pages/viewpage.action ?pageId=7301625
Also, let me give you an example:
package main
import (
"github.com/gogf/gf/v2/frame/g""github.com/gogf/gf/v2/net/gclient""net/http"
)
funcmain() {
c:=g.Client()
c.Use(func(c*gclient.Client, r*http.Request) (resp*gclient.Response, errerror) {
// 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)
returnresp, err
})
}
Description
#3758
我在这个问题里面提到,如果我想避免请求头首字母被改变,只能用go官方的方法.gf官方的包能不能出多一个方法兼容.
Additional
No response
The text was updated successfully, but these errors were encountered: