]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: httpclient: only check co_data() instead of HTTP_MSG_DATA
authorWilliam Lallemand <wlallemand@haproxy.org>
Thu, 17 Mar 2022 13:45:46 +0000 (14:45 +0100)
committerWilliam Lallemand <wlallemand@haproxy.org>
Fri, 18 Mar 2022 10:34:10 +0000 (11:34 +0100)
Checking msg >= HTTP_MSG_DATA was useful to check if we received all the
data. However it does not work correctly in case of errors because we
don't reach this state, preventing to catch the error in the httpclient.

The consequence of this problem is that we don't get the status code of
the error response upon an error.

Fix the issue by only checking co_data().

Must be backported to 2.5.

src/http_client.c

index f5a29934d3ed223eafe12bba6799270e304bdb47..c449418ed02524356891578271f1cc3293cfaa3c 100644 (file)
@@ -645,7 +645,6 @@ static void httpclient_applet_io_handler(struct appctx *appctx)
        struct stream *s = si_strm(si);
        struct channel *req = &s->req;
        struct channel *res = &s->res;
-       struct http_msg *msg = &s->txn->rsp;
        struct htx_blk *blk = NULL;
        struct htx *htx;
        struct htx_sl *sl = NULL;
@@ -735,7 +734,7 @@ static void httpclient_applet_io_handler(struct appctx *appctx)
 
                        case HTTPCLIENT_S_RES_STLINE:
                                /* copy the start line in the hc structure,then remove the htx block */
-                               if (!co_data(res) || (msg->msg_state < HTTP_MSG_DATA))
+                               if (!co_data(res))
                                        goto more;
                                htx = htxbuf(&res->buf);
                                if (!htx)
@@ -774,7 +773,7 @@ static void httpclient_applet_io_handler(struct appctx *appctx)
                                {
                                        struct http_hdr hdrs[global.tune.max_http_hdr];
 
-                                       if (!co_data(res) || (msg->msg_state < HTTP_MSG_DATA))
+                                       if (!co_data(res))
                                                goto more;
                                        htx = htxbuf(&res->buf);
                                        if (!htx)
@@ -839,7 +838,7 @@ static void httpclient_applet_io_handler(struct appctx *appctx)
                                 * The IO handler removes the htx blocks in the response buffer and
                                 * push them in the hc->res.buf buffer in a raw format.
                                 */
-                               if (!co_data(res) || (msg->msg_state < HTTP_MSG_DATA))
+                               if (!co_data(res))
                                        goto more;
 
                                htx = htxbuf(&res->buf);