Hello gophers, I am trying to read http2 request on a tcp connection, which is set up like this -
cert, err := tls.LoadX509KeyPair(certfile, certkeyfile) if err != nil { return nil, err } tlsConfig := &tls.Config{ Certificates: []tls.Certificate{cert}, ServerName: "mysrvr", NextProtos: []string{"h2", "http/1.1", "http/1.0"}, Time: time.Now, Rand: rand.Reader, } tlsConfig.BuildNameToCertificate() tlsConfig.PreferServerCipherSuites = true listener := tls.Listen("tcp", ":"+sqp.ListenerPort, tlsConfig) for { conn, err := listener.Accept() reader := bufio.NewReader(conn) req, err := http.ReadRequest(reader) // problem here // do other things with req } When I do **curl https://127.0.0.1:8000 -k --http2** to the above server, I was expecting http.ReadRequest to parse the request same as it does for http/1.1 or 1.0. What I saw was that the request contained PRI method (which is defined in http2 rfc) and even if I ignore the complete connection preface and the SETTINGS frame after it, I still don't get the original request. Though if I try reading directly from tcp connection, I get a blob right after PRI and SETTINGS frame. I looked at ParseHTTPVersion (https://golang.org/src/net/http/request.go?s=29537:29588#L708) called from readRequest and it doesn't even have a case for HTTP/2. Does it mean I can't use http.ReadRequest for HTTP/2 requests? -- *::DISCLAIMER:: ---------------------------------------------------------------------------------------------------------------------------------------------------- The contents of this e-mail and any attachments are confidential and intended for the named recipient(s) only.E-mail transmission is not guaranteed to be secure or error-free as information could be intercepted, corrupted,lost, destroyed, arrive late or incomplete, or may contain viruses in transmission. The e mail and its contents(with or without referred errors) shall therefore not attach any liability on the originator or redBus.com. Views or opinions, if any, presented in this email are solely those of the author and may not necessarily reflect the views or opinions of redBus.com. Any form of reproduction, dissemination, copying, disclosure, modification,distribution and / or publication of this message without the prior written consent of authorized representative of redbus. <http://redbus.in/>com is strictly prohibited. If you have received this email in error please delete it and notify the sender immediately.Before opening any email and/or attachments, please check them for viruses and other defects.* -- *::DISCLAIMER:: ---------------------------------------------------------------------------------------------------------------------------------------------------- The contents of this e-mail and any attachments are confidential and intended for the named recipient(s) only.E-mail transmission is not guaranteed to be secure or error-free as information could be intercepted, corrupted,lost, destroyed, arrive late or incomplete, or may contain viruses in transmission. The e mail and its contents(with or without referred errors) shall therefore not attach any liability on the originator or redBus.com. Views or opinions, if any, presented in this email are solely those of the author and may not necessarily reflect the views or opinions of redBus.com. Any form of reproduction, dissemination, copying, disclosure, modification,distribution and / or publication of this message without the prior written consent of authorized representative of redbus. <http://redbus.in/>com is strictly prohibited. If you have received this email in error please delete it and notify the sender immediately.Before opening any email and/or attachments, please check them for viruses and other defects.* -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.