We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Describe the bug
假设请求完整路径是http://127.0.0.1/ping时,c.Request.RequestURI()方法的值是/ping。 但是,当启用TLS后,完整路径变成https://127.0.0.1/ping时,c.Request.RequestURI()方法的值是https://127.0.0.1/ping。
http://127.0.0.1/ping
c.Request.RequestURI()
/ping
https://127.0.0.1/ping
显然,对于http和https两种监听模式下, 该方法返回的值的形式不统一,我认为这是一个bug
To Reproduce 复现代码:
package main import ( "context" "crypto/tls" "fmt" "os" "time" "github.com/cloudwego/hertz/pkg/app" "github.com/cloudwego/hertz/pkg/app/server" "github.com/cloudwego/hertz/pkg/protocol/consts" "github.com/hertz-contrib/http2/config" "github.com/hertz-contrib/http2/factory" "golang.org/x/net/http2" ) func main() { // set TLS server // default is standard.NewTransporter h1 := CreateHttpsServer() h1.GET("/ping", func(ctx context.Context, c *app.RequestContext) { fmt.Println("TLS:" + string(c.Request.RequestURI())) c.String(consts.StatusOK, "TLS test\n") }) go h1.Spin() h2 := CreateHttpServer() h2.GET("/ping", func(ctx context.Context, c *app.RequestContext) { fmt.Println("HTTP:" + string(c.Request.RequestURI())) c.String(consts.StatusOK, "http test\n") }) h2.Spin() } // 创建https服务 func CreateHttpsServer() *server.Hertz { // 读取文件内容 certPEM, err := os.ReadFile("./certificate.crt") if err != nil { panic(err) } keyPEM, err := os.ReadFile("./private.key") if err != nil { panic(err) } cert, err := tls.X509KeyPair(certPEM, keyPEM) if err != nil { fmt.Println(err.Error()) } cfg := &tls.Config{ // add certificate Certificates: []tls.Certificate{cert}, MaxVersion: tls.VersionTLS13, // cipher suites supported CipherSuites: []uint16{ tls.TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305, tls.TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384, tls.TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, }, // set application protocol http2 NextProtos: []string{http2.NextProtoTLS}, } h := server.New(server.WithHostPorts(":https"), server.WithALPN(true), server.WithTLS(cfg)) // register http2 server factory h.AddProtocol("h2", factory.NewServerFactory( config.WithReadTimeout(time.Minute), config.WithDisableKeepAlive(false))) cfg.NextProtos = append(cfg.NextProtos, "h2") return h } // 创建http服务 func CreateHttpServer() *server.Hertz { return server.Default(server.WithHostPorts(":http")) }
Expected behavior 期望该方法返回的值的形式保持一致
Hertz version:
v0.9.3
Environment:
go 1.22
The text was updated successfully, but these errors were encountered:
谢谢反馈,的确像一个BUG,我们看看。
Sorry, something went wrong.
@Jeremyly 请问你去掉http2的配置,还能复现问题吗?
@Jeremyly 请问你去掉http2的配置,还能复现问题吗? 去掉 http2的配置确实就不存在这个问题了,所以问题出在http2上?
@Jeremyly 是的。http2不是hertz本身所提供的核心功能, 相应的实现与hertz没关。请到相应的仓库反馈。
No branches or pull requests
Describe the bug
假设请求完整路径是
http://127.0.0.1/ping
时,c.Request.RequestURI()
方法的值是/ping
。但是,当启用TLS后,完整路径变成
https://127.0.0.1/ping
时,c.Request.RequestURI()
方法的值是https://127.0.0.1/ping
。显然,对于http和https两种监听模式下, 该方法返回的值的形式不统一,我认为这是一个bug
To Reproduce
复现代码:
Expected behavior
期望该方法返回的值的形式保持一致
Hertz version:
v0.9.3
Environment:
go 1.22
The text was updated successfully, but these errors were encountered: