Erik Dubbelboer
2018-08-17 16:17:52 +08:00
parent 3d4ce5b57c
commit b3b6b8cb28
3 changed files with 2 additions and 13 deletions
-6
View File
@@ -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.
-3
View File
@@ -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")
}
+2 -4
View File
@@ -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 {