in mux.go [123:146]
func (m *mux) handleH2(srv *http.Server, conn net.Conn, handler http.Handler) error {
var clientReadBuf bytes.Buffer
connHandler, err := m.getConnHandler(conn, &clientReadBuf)
if err != nil {
return err
}
// Write frames from the server to a pipe so that we can de-duplicate the first
// SETTINGS ACK. The client's first SETTINGS is handled twice: once in getConnHandler,
// and once in the final connHandler. As getConnHandler will ACK the SETTINGS,
// we need to filter out the second one ade by the final connHandler.
rpipe, wpipe := io.Pipe()
go func() {
if err := copyFramesUntilSettingsAck(conn, rpipe); err != nil {
rpipe.CloseWithError(err)
return
}
_, err := io.Copy(conn, rpipe)
rpipe.CloseWithError(err)
}()
proxyConn, closed := newProxyConn(conn, io.MultiReader(&clientReadBuf, conn), wpipe)
err = connHandler(srv, proxyConn, closed, handler)
wpipe.CloseWithError(err)
return err
}