From 6194168d4ecda939d5bb94da6e4533036216dbc8 Mon Sep 17 00:00:00 2001 From: Soheil Hassas Yeganeh Date: Wed, 29 Jul 2015 17:23:53 -0400 Subject: [PATCH] Remove the bugos http2.Configure from tests http2.Configure is not functional with cmux. Asked for exporting http2.Server.HandleConn(). --- cmux_test.go | 13 ++++--------- example_test.go | 6 +++--- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/cmux_test.go b/cmux_test.go index 343d294..67df37d 100644 --- a/cmux_test.go +++ b/cmux_test.go @@ -7,8 +7,6 @@ import ( "net/http" "net/rpc" "testing" - - "github.com/bradfitz/http2" ) const ( @@ -38,13 +36,10 @@ func (h *testHTTP1Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) { fmt.Fprintf(w, testHTTP1Resp) } -func runTestHTTPServer(l net.Listener, withHTTP2 bool) { +func runTestHTTPServer(l net.Listener) { s := &http.Server{ Handler: &testHTTP1Handler{}, } - if withHTTP2 { - http2.ConfigureServer(s, &http2.Server{}) - } s.Serve(l) } @@ -110,7 +105,7 @@ func TestAny(t *testing.T) { muxl := New(l) httpl := muxl.Match(Any()) - go runTestHTTPServer(httpl, false) + go runTestHTTPServer(httpl) go muxl.Serve() r, err := http.Get("http://" + addr) @@ -133,7 +128,7 @@ func TestHTTPGoRPC(t *testing.T) { httpl := muxl.Match(HTTP2(), HTTP1Fast()) rpcl := muxl.Match(Any()) - go runTestHTTPServer(httpl, true) + go runTestHTTPServer(httpl) go runTestRPCServer(rpcl) go muxl.Serve() @@ -148,7 +143,7 @@ func TestErrorHandler(t *testing.T) { muxl := New(l) httpl := muxl.Match(HTTP2(), HTTP1Fast()) - go runTestHTTPServer(httpl, true) + go runTestHTTPServer(httpl) go muxl.Serve() firstErr := true diff --git a/example_test.go b/example_test.go index 7271421..086e12b 100644 --- a/example_test.go +++ b/example_test.go @@ -66,9 +66,9 @@ func Example() { // We first match the connection against HTTP2 fields. If matched, the // connection will be sent through the "grpcl" listener. grpcl := m.Match(cmux.HTTP2HeaderField("content-type", "application/grpc")) - // Otherwise, we match it againts HTTP1 methods and HTTP2. If matched by - // any of them, it is sent through the "httpl" listener. - httpl := m.Match(cmux.HTTP1Fast(), cmux.HTTP2()) + // Otherwise, we match it againts HTTP1 methods. If matched, + // it is sent through the "httpl" listener. + httpl := m.Match(cmux.HTTP1Fast()) // If not matched by HTTP, we assume it is an RPC connection. rpcl := m.Match(cmux.Any())