mirror of
https://github.com/soheilhy/cmux.git
synced 2026-09-03 01:04:32 +08:00
Compare commits
2 Commits
dev/settin
...
dev/go10
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
711042c095 | ||
|
|
ac00452023 |
3
cmux.go
3
cmux.go
@@ -116,9 +116,8 @@ type cMux struct {
|
|||||||
func matchersToMatchWriters(matchers []Matcher) []MatchWriter {
|
func matchersToMatchWriters(matchers []Matcher) []MatchWriter {
|
||||||
mws := make([]MatchWriter, 0, len(matchers))
|
mws := make([]MatchWriter, 0, len(matchers))
|
||||||
for _, m := range matchers {
|
for _, m := range matchers {
|
||||||
cm := m
|
|
||||||
mws = append(mws, func(w io.Writer, r io.Reader) bool {
|
mws = append(mws, func(w io.Writer, r io.Reader) bool {
|
||||||
return cm(r)
|
return m(r)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
return mws
|
return mws
|
||||||
|
|||||||
29
cmux_test.go
29
cmux_test.go
@@ -622,35 +622,6 @@ 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) {
|
func TestClose(t *testing.T) {
|
||||||
defer leakCheck(t)()
|
defer leakCheck(t)()
|
||||||
errCh := make(chan error)
|
errCh := make(chan error)
|
||||||
|
|||||||
@@ -240,11 +240,6 @@ func matchHTTP2Field(w io.Writer, r io.Reader, name string, matches func(string)
|
|||||||
|
|
||||||
switch f := f.(type) {
|
switch f := f.(type) {
|
||||||
case *http2.SettingsFrame:
|
case *http2.SettingsFrame:
|
||||||
// Sender acknoweldged the SETTINGS frame. No need to write
|
|
||||||
// SETTINGS again.
|
|
||||||
if f.IsAck() {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
if err := framer.WriteSettings(); err != nil {
|
if err := framer.WriteSettings(); err != nil {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user