]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: http-client: Trigger an error if first response block isn't a start-line
authorChristopher Faulet <cfaulet@haproxy.com>
Tue, 22 Jul 2025 06:22:06 +0000 (08:22 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Thu, 24 Jul 2025 10:13:42 +0000 (12:13 +0200)
The first HTX block of a response must be a start-line. There is no reason
to wait for something else. And if there are output data in the response
channel buffer, it means we must found the start-line.

src/http_client.c

index b881383e7a98dc0492d7dc6153a4887c0f97259e..49aba5ba28496a801d40746c1da44c0d53e03c34 100644 (file)
@@ -654,13 +654,10 @@ void httpclient_applet_io_handler(struct appctx *appctx)
                                if (!co_data(res))
                                        goto out;
                                htx = htxbuf(&res->buf);
-                               if (htx_is_empty(htx))
-                                       goto out;
-                               blk = htx_get_head_blk(htx);
-                               if (blk && (htx_get_blk_type(blk) == HTX_BLK_RES_SL))
-                                       sl = htx_get_blk_ptr(htx, blk);
-                               if (!sl || (!(sl->flags & HTX_SL_F_IS_RESP)))
-                                       goto out;
+                               if (htx_get_first_type(htx) != HTX_BLK_RES_SL)
+                                       goto error;
+                               blk = DISGUISE(htx_get_head_blk(htx));
+                                sl = htx_get_blk_ptr(htx, blk);
 
                                /* Skipp any 1XX interim responses */
                                if (sl->info.res.status < 200) {