mirror of
https://github.com/soheilhy/cmux.git
synced 2025-10-18 05:08:08 +08:00
Compare commits
6 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
e09e9389d8 | ||
|
444ce56efe | ||
|
cfc68f9888 | ||
|
e96bd75f84 | ||
|
be5b383fd5 | ||
|
b9e684ba4e |
3
cmux.go
3
cmux.go
@@ -116,8 +116,9 @@ type cMux struct {
|
||||
func matchersToMatchWriters(matchers []Matcher) []MatchWriter {
|
||||
mws := make([]MatchWriter, 0, len(matchers))
|
||||
for _, m := range matchers {
|
||||
cm := m
|
||||
mws = append(mws, func(w io.Writer, r io.Reader) bool {
|
||||
return m(r)
|
||||
return cm(r)
|
||||
})
|
||||
}
|
||||
return mws
|
||||
|
29
cmux_test.go
29
cmux_test.go
@@ -622,6 +622,35 @@ func TestErrorHandler(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestMultipleMatchers(t *testing.T) {
|
||||
defer leakCheck(t)()
|
||||
errCh := make(chan error)
|
||||
defer func() {
|
||||
select {
|
||||
case err := <-errCh:
|
||||
t.Fatal(err)
|
||||
default:
|
||||
}
|
||||
}()
|
||||
l, cleanup := testListener(t)
|
||||
defer cleanup()
|
||||
|
||||
matcher := func(r io.Reader) bool {
|
||||
return true
|
||||
}
|
||||
unmatcher := func(r io.Reader) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
muxl := New(l)
|
||||
lis := muxl.Match(unmatcher, matcher, unmatcher)
|
||||
|
||||
go runTestHTTPServer(errCh, lis)
|
||||
go safeServe(errCh, muxl)
|
||||
|
||||
runTestHTTP1Client(t, l.Addr())
|
||||
}
|
||||
|
||||
func TestClose(t *testing.T) {
|
||||
defer leakCheck(t)()
|
||||
errCh := make(chan error)
|
||||
|
@@ -240,6 +240,11 @@ func matchHTTP2Field(w io.Writer, r io.Reader, name string, matches func(string)
|
||||
|
||||
switch f := f.(type) {
|
||||
case *http2.SettingsFrame:
|
||||
// Sender acknoweldged the SETTINGS frame. No need to write
|
||||
// SETTINGS again.
|
||||
if f.IsAck() {
|
||||
break
|
||||
}
|
||||
if err := framer.WriteSettings(); err != nil {
|
||||
return false
|
||||
}
|
||||
|
Reference in New Issue
Block a user