2
0
mirror of https://github.com/soheilhy/cmux.git synced 2024-11-10 03:31:52 +08:00

feat: avoid writing multiple settings

This commit is contained in:
luke 2023-12-19 17:15:44 +08:00
parent 677b4b20e7
commit 51cff2c8bc

View File

@ -266,10 +266,12 @@ func matchHTTP2Field(w io.Writer, r io.Reader, name string, matches func(string)
waitAcks-- waitAcks--
break break
} }
if waitAcks <= 0 {
if err := framer.WriteSettings(); err != nil { if err := framer.WriteSettings(); err != nil {
return false return false
} }
waitAcks++ waitAcks++
}
case *http2.ContinuationFrame: case *http2.ContinuationFrame:
if _, err := hdec.Write(f.HeaderBlockFragment()); err != nil { if _, err := hdec.Write(f.HeaderBlockFragment()); err != nil {
return false return false
@ -282,7 +284,7 @@ func matchHTTP2Field(w io.Writer, r io.Reader, name string, matches func(string)
done = done || f.FrameHeader.Flags&http2.FlagHeadersEndHeaders != 0 done = done || f.FrameHeader.Flags&http2.FlagHeadersEndHeaders != 0
} }
if done && waitAcks == 0 { if done && waitAcks <= 0 {
return matched return matched
} }
} }