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,11 +86,17 @@ func (c *http2Conn) Read(p []byte) (int, error) {
|
|||||||
}
|
}
|
||||||
n, err := c.Conn.Read(p)
|
n, err := c.Conn.Read(p)
|
||||||
for i := range n {
|
for i := range n {
|
||||||
// first mismatch, close the connection if h2 is expected
|
// first mismatch
|
||||||
if p[i] != http2.ClientPreface[c.idx] && c.h2Expected {
|
if p[i] != http2.ClientPreface[c.idx] {
|
||||||
c.logger.Debug("h1 connection detected, but h1 is not enabled")
|
// close the connection if h2 is expected
|
||||||
_ = c.Conn.Close()
|
if c.h2Expected {
|
||||||
return 0, io.EOF
|
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++
|
c.idx++
|
||||||
// matching complete
|
// matching complete
|
||||||
|
Loading…
x
Reference in New Issue
Block a user