]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MEDIUM: httpclient: set res.status to 0 upon SF_ERR_MASK
authorWilliam Lallemand <wlallemand@irq6.net>
Sun, 14 Jun 2026 08:46:38 +0000 (10:46 +0200)
committerWilliam Lallemand <wlallemand@irq6.net>
Sun, 14 Jun 2026 08:46:38 +0000 (10:46 +0200)
With the httpclient it's difficult to get if the HTTP status code was
returned by the actual server or if it's the internal proxy that
generate the error.

This patch changes the behavior by setting the status to 0 when an error
is get by the stream.

There were already valid cases when the status was 0 on some error, so
that should not really change the error path in the scripts.

src/http_client.c

index c1937c4711cfb1ef7f81819fad7d084b4315783c..fa205f0f0b04fbf16edb7ec09b85809728e63aef 100644 (file)
@@ -688,6 +688,10 @@ void httpclient_applet_io_handler(struct appctx *appctx)
 
                                /* copy the status line in the httpclient */
                                hc->res.status = sl->info.res.status;
+
+                               if (__sc_strm(appctx_sc(appctx))->flags & SF_ERR_MASK)
+                                       hc->res.status = 0;
+
                                hc->res.vsn = istdup(htx_sl_res_vsn(sl));
                                hc->res.reason = istdup(htx_sl_res_reason(sl));
                                htx_remove_blk(htx, blk);