]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
CLEANUP: http-client: Remove useless indentation when sending request body
authorChristopher Faulet <cfaulet@haproxy.com>
Tue, 22 Jul 2025 06:14:24 +0000 (08:14 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Thu, 24 Jul 2025 10:06:48 +0000 (12:06 +0200)
It was useless to have an indentation to handle HTTPCLIENT_S_REQ_BODY state
in the http-client I/O handler.

src/http_client.c

index 8381e043435bae0e6e72c4f649cdfa6378895c84..4740933891568caf305c1d7e20817ea64a4b6c3e 100644 (file)
@@ -534,7 +534,6 @@ void httpclient_applet_io_handler(struct appctx *appctx)
                goto out;
 
        while (1) {
-
                /* required to stop */
                if (hc->flags & HTTPCLIENT_FA_STOP)
                        goto error;
@@ -575,77 +574,74 @@ void httpclient_applet_io_handler(struct appctx *appctx)
 
                        case HTTPCLIENT_S_REQ_BODY:
                                /* call the payload callback */
-                               {
-                                       if (hc->ops.req_payload) {
-                                               struct htx *hc_htx;
-
-                                               if (co_data(res)) {
-                                                       /* A response was received but we are still process the request.
-                                                        * It is unexpected and not really supported with the current API.
-                                                        * So lets drain the request to avoid any issue.
-                                                        */
-                                                       b_reset(&hc->req.buf);
-                                                       hc->flags |= HTTPCLIENT_FA_DRAIN_REQ;
-                                                       appctx->st0 = HTTPCLIENT_S_RES_STLINE;
-                                                       break;
-                                               }
-
-                                               /* call the request callback */
-                                               hc->ops.req_payload(hc);
+                               if (hc->ops.req_payload) {
+                                       struct htx *hc_htx;
 
-                                               hc_htx = htxbuf(&hc->req.buf);
-                                               if (htx_is_empty(hc_htx))
-                                                       goto out;
+                                       if (co_data(res)) {
+                                               /* A response was received but we are still process the request.
+                                                * It is unexpected and not really supported with the current API.
+                                                * So lets drain the request to avoid any issue.
+                                                */
+                                               b_reset(&hc->req.buf);
+                                               hc->flags |= HTTPCLIENT_FA_DRAIN_REQ;
+                                               appctx->st0 = HTTPCLIENT_S_RES_STLINE;
+                                               break;
+                                       }
 
-                                               htx = htx_from_buf(&req->buf);
-                                               if (htx_is_empty(htx)) {
-                                                       size_t data = hc_htx->data;
-
-                                                       /* Here htx_to_buf() will set buffer data to 0 because
-                                                        * the HTX is empty, and allow us to do an xfer.
-                                                        */
-                                                       htx_to_buf(hc_htx, &hc->req.buf);
-                                                       htx_to_buf(htx, &req->buf);
-                                                       b_xfer(&req->buf, &hc->req.buf, b_data(&hc->req.buf));
-                                                       channel_add_input(req, data);
-                                               } else {
-                                                       struct htx_ret ret;
-                                                       size_t data = htx->data;
+                                       /* call the request callback */
+                                       hc->ops.req_payload(hc);
 
-                                                       ret = htx_xfer_blks(htx, hc_htx, htx_used_space(hc_htx), HTX_BLK_UNUSED);
-                                                       if (!ret.ret) {
-                                                               sc_need_room(sc, channel_htx_recv_max(req, htx) + 1);
-                                                               goto out;
-                                                       }
-                                                       data = htx->data - data;
-                                                       channel_add_input(req, data);
+                                       hc_htx = htxbuf(&hc->req.buf);
+                                       if (htx_is_empty(hc_htx))
+                                               goto out;
 
-                                                       /* we must copy the EOM if we empty the buffer */
-                                                       if (htx_is_empty(hc_htx)) {
-                                                               htx->flags |= (hc_htx->flags & HTX_FL_EOM);
-                                                       }
-                                                       htx_to_buf(htx, &req->buf);
-                                                       htx_to_buf(hc_htx, &hc->req.buf);
+                                       htx = htx_from_buf(&req->buf);
+                                       if (htx_is_empty(htx)) {
+                                               size_t data = hc_htx->data;
+
+                                               /* Here htx_to_buf() will set buffer data to 0 because
+                                                * the HTX is empty, and allow us to do an xfer.
+                                                */
+                                               htx_to_buf(hc_htx, &hc->req.buf);
+                                               htx_to_buf(htx, &req->buf);
+                                               b_xfer(&req->buf, &hc->req.buf, b_data(&hc->req.buf));
+                                               channel_add_input(req, data);
+                                       } else {
+                                               struct htx_ret ret;
+                                               size_t data = htx->data;
+
+                                               ret = htx_xfer_blks(htx, hc_htx, htx_used_space(hc_htx), HTX_BLK_UNUSED);
+                                               if (!ret.ret) {
+                                                       sc_need_room(sc, channel_htx_recv_max(req, htx) + 1);
+                                                       goto out;
                                                }
+                                               data = htx->data - data;
+                                               channel_add_input(req, data);
 
-
-                                               if (!b_data(&hc->req.buf))
-                                                       b_free(&hc->req.buf);
+                                               /* we must copy the EOM if we empty the buffer */
+                                               if (htx_is_empty(hc_htx)) {
+                                                       htx->flags |= (hc_htx->flags & HTX_FL_EOM);
+                                               }
+                                               htx_to_buf(htx, &req->buf);
+                                               htx_to_buf(hc_htx, &hc->req.buf);
                                        }
 
-                                       htx = htxbuf(&req->buf);
 
-                                       /* if the request contains the HTX_FL_EOM, we finished the request part. */
-                                       if (htx->flags & HTX_FL_EOM) {
-                                               appctx->st0 = HTTPCLIENT_S_RES_STLINE;
-                                               se_fl_set(appctx->sedesc, SE_FL_EOI);
-                                               break;
-                                       }
+                                       if (!b_data(&hc->req.buf))
+                                               b_free(&hc->req.buf);
+                               }
+
+                               htx = htxbuf(&req->buf);
 
-                                       applet_have_more_data(appctx);
-                                       goto process_data; /* we need to leave the IO handler once we wrote the request */
+                               /* if the request contains the HTX_FL_EOM, we finished the request part. */
+                               if (htx->flags & HTX_FL_EOM) {
+                                       appctx->st0 = HTTPCLIENT_S_RES_STLINE;
+                                       se_fl_set(appctx->sedesc, SE_FL_EOI);
+                                       break;
                                }
-                               break;
+
+                               applet_have_more_data(appctx);
+                               goto process_data; /* we need to leave the IO handler once we wrote the request */
 
                        case HTTPCLIENT_S_RES_STLINE:
                                /* in HTX mode, don't try to copy the stline