-
Notifications
You must be signed in to change notification settings - Fork 933
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
triple request missed http header like scheme, host etc. #2642
Comments
Solution by @2456868764 in #2643 setHTTPSHeaders := func(h http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
// Set http scheme header
r.Header.Set(":x-scheme", "https")
r.Header.Set(":x-host", r.Host)
r.Header.Set(":x-path", r.RequestURI)
r.Header.Set(":x-method", r.Method)
certs := r.TLS.PeerCertificates
if len(certs) > 0 {
peerCert := certs[0]
if len(peerCert.URIs) > 0 {
spiffeURI := peerCert.URIs[0].String()
// Set spiffe scheme header
r.Header.Set(":x-spiffe", spiffeURI)
}
}
h.ServeHTTP(w, r)
})
} |
这个设置头部做法在 http2下有问题,一开始有个 method = PRI 协商协议,这个时候是不能设置头部,否则这个协商协议就挂, 要看是否有更合适解决方案 @chickenlj |
我现在做法: dubbo-go/protocol/triple/triple_protocol/server.go 启动两个端口,一个http, 一个 HTTPS 代码如下 :
HTTPS 可以设置自定义头, HTTP不可以,因为http 一进来就是走了 r.Method == "PRI",这个时候不能设置自定义头。
也做了其他trick做法,我现在trick做法 HTTP不设置定义头,HTTPS设置,后续在 dubbo filter 判断再补全, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Environment
Issue description
The user story is to get if the current request is https or http.
there is dubbo filter demo code which just output attachments :
and output as follow:
and miss some common http headers like scheme ,host etc.
Logs
Click me to check logs
The text was updated successfully, but these errors were encountered: