mirror of
https://github.com/caddyserver/caddy.git
synced 2025-05-24 02:02:26 -04:00
fix matching if only h1 is enabled
This commit is contained in:
parent
c28bab9cb3
commit
4158f9e8d5
@ -86,12 +86,18 @@ func (c *http2Conn) Read(p []byte) (int, error) {
|
||||
}
|
||||
n, err := c.Conn.Read(p)
|
||||
for i := range n {
|
||||
// first mismatch, close the connection if h2 is expected
|
||||
if p[i] != http2.ClientPreface[c.idx] && c.h2Expected {
|
||||
// first mismatch
|
||||
if p[i] != http2.ClientPreface[c.idx] {
|
||||
// close the connection if h2 is expected
|
||||
if c.h2Expected {
|
||||
c.logger.Debug("h1 connection detected, but h1 is not enabled")
|
||||
_ = c.Conn.Close()
|
||||
return 0, io.EOF
|
||||
}
|
||||
// no need to continue matching anymore
|
||||
c.idx = len(http2.ClientPreface)
|
||||
return n, err
|
||||
}
|
||||
c.idx++
|
||||
// matching complete
|
||||
if c.idx == len(http2.ClientPreface) && !c.h2Expected {
|
||||
|
Loading…
x
Reference in New Issue
Block a user