mirror of
https://github.com/soheilhy/cmux.git
synced 2024-11-09 19:21:52 +08:00
Remove the bugos http2.Configure from tests
http2.Configure is not functional with cmux. Asked for exporting http2.Server.HandleConn().
This commit is contained in:
parent
549d3f9344
commit
6194168d4e
13
cmux_test.go
13
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
|
||||
|
@ -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())
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user