Skip to content
This repository was archived by the owner on Sep 17, 2019. It is now read-only.
This repository was archived by the owner on Sep 17, 2019. It is now read-only.

Exporting Server.handleConn #69

@soheilhy

Description

@soheilhy

Server.handleConn is the minimum required to implement an http2 server outside net/http, say to implement h2c:

s := &http.Server{
    Handler: &myHandler{},
}
s2 := &http2.Server{}
for {
    c, err := l.Accept()
    if err != nil {
        if terr, ok := err.(net.Error); ok && terr.Temporary() {
            continue
        }
        return
    }
    go s2.HandleConn(s, c, s.Handler)
}

I have another selfish reason for that. I've built a connection multiplexer that sniffs connections to multiplex them. Using that, I can run net/rpc, gRPC, and HTTP1.1 on the same port. However, I can't do that for HTTP2 because I have to wrap the actual connection in a cmux connection. So, the "fake" connection is not a *tls.Conn and TLSNextProto handlers would never be called for HTTP2 flows.

Would you please consider exporting this method?

Just in case, I confirm that using the snippet above I can serve h2 (i.e., chrome) and gRPC/TLS traffic on the same port.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions