]> git.kaiwu.me - haproxy.git/commitdiff
BUG/MINOR: http-ana: call the http_reset filter callback on L7 retries
authorAleksandar Lazic <al-haproxy@none.at>
Wed, 21 Oct 2026 20:25:18 +0000 (22:25 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Thu, 22 Oct 2026 14:58:07 +0000 (16:58 +0200)
The filters documentation says that the http_reset callback is called
when the request is sent again to the server for a L7 retry, but it was
only called for the 1xx informational responses. It was documented with
the L7 retries in commit a254a37ad ("MEDIUM: streams: Add the ability to
retry a request on L7 failure."), but never called on this path.

do_l7_retry() now calls it for the response, once sc_reset_endp()
succeeded so that the retry is certain, and before the L7 buffer swap,
while the failed response is still in the buffer and txn->status is
set, like for the 1xx responses. The request is sent again as is from
the L7 buffer and its callbacks are not called again, so it is not
reset. The documentation now tells it.

This patch could be backported to all stable versions.

Signed-off-by: Aleksandar Lazic <al-haproxy@none.at>
doc/internals/api/filters.txt
src/filters.c
src/http_ana.c

index 5a83505f55406ecaecf9c7ba800b0c07b1f5b275..87898b45dbd63bb4602c6e2725c05a0f41ddf5f5 100644 (file)
@@ -1578,6 +1578,9 @@ Then, to finish, there are 2 informational callbacks :
     By checking s->txn.http->status, it is possible to know why this callback is
     called. If it's a 1xx, we're called because of an informational
     message. Otherwise, it is a L7 retry.
+    On a L7 retry, it is only called for the response, once the retry is
+    certain, while the failed response, if any, is still in the channel buffer.
+    The request is sent again as is, so its callbacks are not called again.
 
   * 'flt_ops.http_reply' : This callback is called when, at any time, HAProxy
     decides to stop the processing on a HTTP message and to send an internal
index fc521b811846f62ef754a42a04bf55bfbceb7b88..698ddfafdbd48f3c89b5f2a1a19758c4c02ca234 100644 (file)
@@ -1331,7 +1331,8 @@ end:
 
 /*
  * Calls 'http_reset' callback for all filters attached to a stream. This
- * happens when a 100-continue response is received.
+ * happens when a 1xx informational response is received, and on the response
+ * when the request is sent again for a L7 retry.
  */
 void
 flt_http_reset(struct stream *s, struct http_msg *msg)
index 397680595627260a689cdaca52ecb9e9ef8ec1b4..f17a40fc50dc3223fee0dc563f39646f411d89ac 100644 (file)
@@ -1225,6 +1225,12 @@ static __inline int do_l7_retry(struct stream *s, struct stconn *sc)
                return -1;
        }
 
+       /* The retry is now certain: notify the filters that the response is
+        * reset, while the failed one is still in the buffer. The request is
+        * sent again as is from the L7 buffer, so it is not reset.
+        */
+       FLT_STRM_CB(s, flt_http_reset(s, &s->txn.http->rsp));
+
        b_free(&req->buf);
 
        /* Swap the L7 buffer with the channel buffer */