mirror of
https://github.com/soheilhy/cmux.git
synced 2024-11-10 03:31: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/http"
|
||||||
"net/rpc"
|
"net/rpc"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/bradfitz/http2"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -38,13 +36,10 @@ func (h *testHTTP1Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||||||
fmt.Fprintf(w, testHTTP1Resp)
|
fmt.Fprintf(w, testHTTP1Resp)
|
||||||
}
|
}
|
||||||
|
|
||||||
func runTestHTTPServer(l net.Listener, withHTTP2 bool) {
|
func runTestHTTPServer(l net.Listener) {
|
||||||
s := &http.Server{
|
s := &http.Server{
|
||||||
Handler: &testHTTP1Handler{},
|
Handler: &testHTTP1Handler{},
|
||||||
}
|
}
|
||||||
if withHTTP2 {
|
|
||||||
http2.ConfigureServer(s, &http2.Server{})
|
|
||||||
}
|
|
||||||
s.Serve(l)
|
s.Serve(l)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -110,7 +105,7 @@ func TestAny(t *testing.T) {
|
|||||||
muxl := New(l)
|
muxl := New(l)
|
||||||
httpl := muxl.Match(Any())
|
httpl := muxl.Match(Any())
|
||||||
|
|
||||||
go runTestHTTPServer(httpl, false)
|
go runTestHTTPServer(httpl)
|
||||||
go muxl.Serve()
|
go muxl.Serve()
|
||||||
|
|
||||||
r, err := http.Get("http://" + addr)
|
r, err := http.Get("http://" + addr)
|
||||||
@ -133,7 +128,7 @@ func TestHTTPGoRPC(t *testing.T) {
|
|||||||
httpl := muxl.Match(HTTP2(), HTTP1Fast())
|
httpl := muxl.Match(HTTP2(), HTTP1Fast())
|
||||||
rpcl := muxl.Match(Any())
|
rpcl := muxl.Match(Any())
|
||||||
|
|
||||||
go runTestHTTPServer(httpl, true)
|
go runTestHTTPServer(httpl)
|
||||||
go runTestRPCServer(rpcl)
|
go runTestRPCServer(rpcl)
|
||||||
go muxl.Serve()
|
go muxl.Serve()
|
||||||
|
|
||||||
@ -148,7 +143,7 @@ func TestErrorHandler(t *testing.T) {
|
|||||||
muxl := New(l)
|
muxl := New(l)
|
||||||
httpl := muxl.Match(HTTP2(), HTTP1Fast())
|
httpl := muxl.Match(HTTP2(), HTTP1Fast())
|
||||||
|
|
||||||
go runTestHTTPServer(httpl, true)
|
go runTestHTTPServer(httpl)
|
||||||
go muxl.Serve()
|
go muxl.Serve()
|
||||||
|
|
||||||
firstErr := true
|
firstErr := true
|
||||||
|
@ -66,9 +66,9 @@ func Example() {
|
|||||||
// We first match the connection against HTTP2 fields. If matched, the
|
// We first match the connection against HTTP2 fields. If matched, the
|
||||||
// connection will be sent through the "grpcl" listener.
|
// connection will be sent through the "grpcl" listener.
|
||||||
grpcl := m.Match(cmux.HTTP2HeaderField("content-type", "application/grpc"))
|
grpcl := m.Match(cmux.HTTP2HeaderField("content-type", "application/grpc"))
|
||||||
// Otherwise, we match it againts HTTP1 methods and HTTP2. If matched by
|
// Otherwise, we match it againts HTTP1 methods. If matched,
|
||||||
// any of them, it is sent through the "httpl" listener.
|
// it is sent through the "httpl" listener.
|
||||||
httpl := m.Match(cmux.HTTP1Fast(), cmux.HTTP2())
|
httpl := m.Match(cmux.HTTP1Fast())
|
||||||
// If not matched by HTTP, we assume it is an RPC connection.
|
// If not matched by HTTP, we assume it is an RPC connection.
|
||||||
rpcl := m.Match(cmux.Any())
|
rpcl := m.Match(cmux.Any())
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user