mirror of
https://github.com/valyala/fasthttp.git
synced 2026-06-26 17:46:34 +03:00
Fix Request.connectionCloseFast bugs
See https://github.com/valyala/fasthttp/pull/265 and https://github.com/valyala/fasthttp/issues/220 and https://github.com/valyala/fasthttp/issues/264
This commit is contained in:
@@ -157,12 +157,6 @@ func (h *RequestHeader) ConnectionClose() bool {
|
||||
return h.connectionClose
|
||||
}
|
||||
|
||||
func (h *RequestHeader) connectionCloseFast() bool {
|
||||
// h.parseRawHeaders() isn't called for performance reasons.
|
||||
// Use ConnectionClose for triggering raw headers parsing.
|
||||
return h.connectionClose
|
||||
}
|
||||
|
||||
// SetConnectionClose sets 'Connection: close' header.
|
||||
func (h *RequestHeader) SetConnectionClose() {
|
||||
// h.parseRawHeaders() isn't called for performance reasons.
|
||||
|
||||
@@ -431,9 +431,6 @@ func TestRequestHeaderHTTP10ConnectionClose(t *testing.T) {
|
||||
t.Fatalf("unexpected error: %s", err)
|
||||
}
|
||||
|
||||
if !h.connectionCloseFast() {
|
||||
t.Fatalf("expecting 'Connection: close' request header")
|
||||
}
|
||||
if !h.ConnectionClose() {
|
||||
t.Fatalf("expecting 'Connection: close' request header")
|
||||
}
|
||||
|
||||
@@ -1746,7 +1746,7 @@ func (s *Server) serveConn(c net.Conn) error {
|
||||
}
|
||||
}
|
||||
|
||||
connectionClose = s.DisableKeepalive || ctx.Request.Header.connectionCloseFast()
|
||||
connectionClose = s.DisableKeepalive || ctx.Request.Header.ConnectionClose()
|
||||
isHTTP11 = ctx.Request.Header.IsHTTP11()
|
||||
|
||||
if serverName != nil {
|
||||
@@ -1785,9 +1785,7 @@ func (s *Server) serveConn(c net.Conn) error {
|
||||
lastWriteDeadlineTime = s.updateWriteDeadline(c, ctx, lastWriteDeadlineTime)
|
||||
}
|
||||
|
||||
// Verify Request.Header.connectionCloseFast() again,
|
||||
// since request handler might trigger full headers' parsing.
|
||||
connectionClose = connectionClose || ctx.Request.Header.connectionCloseFast() || ctx.Response.ConnectionClose()
|
||||
connectionClose = connectionClose || ctx.Response.ConnectionClose()
|
||||
if connectionClose {
|
||||
ctx.Response.Header.SetCanonical(strConnection, strClose)
|
||||
} else if !isHTTP11 {
|
||||
|
||||
Reference in New Issue
Block a user