]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: mux-h2: Reset streams with NO_ERROR code if full response was already...
authorChristopher Faulet <cfaulet@haproxy.com>
Mon, 17 Mar 2025 15:26:35 +0000 (16:26 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Thu, 20 Mar 2025 07:36:06 +0000 (08:36 +0100)
On frontend side, when a stream is shut while the response was already fully
sent, it was cancelled by sending a RST_STREAM(CANCEL) frame. However, it is
not accurrate. CANCEL error code must only be used if the response headers
were sent, but not the full response. As stated in the RFC 9113, when the
response was fully sent, to stop the request sending, a RST_STREAM with an
error code of NO_ERROR must be sent.

This patch should solve the issue #1219. It must be backported to all stable
versions.

src/mux_h2.c

index 68ad3eb3d79880390d6b82427726c9bd20650c4a..948ae26d3bc0f311acf76881c7762e48a73b85ae 100644 (file)
@@ -5540,8 +5540,11 @@ static void h2_do_shutr(struct h2s *h2s, struct se_abort_info *reason)
                 * stream anymore. This may happen when the server responds
                 * before the end of an upload and closes quickly (redirect,
                 * deny, ...)
+                *
+                * RFC9113#8.1: Use NO_ERROR code after a complete response was
+                *              sent (So frontend side and ES sent)
                 */
-               h2s_error(h2s, H2_ERR_CANCEL);
+               h2s_error(h2s, (!(h2c->flags & H2_CF_IS_BACK) && (h2s->flags & H2_SF_ES_SENT)) ? H2_ERR_NO_ERROR : H2_ERR_CANCEL);
        }
 
        if (!(h2s->flags & H2_SF_RST_SENT) &&