// The configuration conf may be nil.
//
// ConfigureServer must be called before s begins serving.
-func http2ConfigureServer(s *Server, conf *http2Server) {
+func http2ConfigureServer(s *Server, conf *http2Server) error {
if conf == nil {
conf = new(http2Server)
}
}
s.TLSNextProto[http2NextProtoTLS] = protoHandler
s.TLSNextProto["h2-14"] = protoHandler
+ return nil // temporary manual edit to h2_bundle.go, to be deleted once we update from x/net again
}
func (srv *http2Server) handleConn(hs *Server, c net.Conn, h Handler) {
disableKeepAlives int32 // accessed atomically.
nextProtoOnce sync.Once // guards initialization of TLSNextProto in Serve
+ nextProtoErr error
}
// A ConnState represents the state of a client connection to a server.
defer l.Close()
var tempDelay time.Duration // how long to sleep on accept failure
srv.nextProtoOnce.Do(srv.setNextProtoDefaults)
+ if srv.nextProtoErr != nil {
+ // Error from http2 ConfigureServer (e.g. bad ciphersuites)
+ return srv.nextProtoErr
+ }
for {
rw, e := l.Accept()
if e != nil {
return srv.Serve(tlsListener)
}
+// setNextProtoDefaults configures HTTP/2.
+// It must only be called via srv.nextProtoOnce.
func (srv *Server) setNextProtoDefaults() {
// Enable HTTP/2 by default if the user hasn't otherwise
// configured their TLSNextProto map.
if srv.TLSNextProto == nil {
- http2ConfigureServer(srv, nil)
+ srv.nextProtoErr = http2ConfigureServer(srv, nil)
}
}