]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: httpclient: Make the CLI flags public for future use
authorRemi Tricot-Le Breton <rlebreton@haproxy.com>
Tue, 20 Dec 2022 10:11:03 +0000 (11:11 +0100)
committerWilliam Lallemand <wlallemand@haproxy.org>
Wed, 21 Dec 2022 10:21:07 +0000 (11:21 +0100)
Those flags used by the http_client in its CLI function might come to
use for OCSP updates that will strongly rely on the http client.

include/haproxy/http_client-t.h
src/http_client.c

index 3d05c0451c4950c622ad45890738e31e7167730f..7ae0e612f0b5f5ab1ca42a4ba7f52c4b795648da 100644 (file)
@@ -59,4 +59,11 @@ enum {
 
 #define HTTPCLIENT_USERAGENT "HAProxy"
 
+/* What kind of data we need to read */
+#define HC_F_RES_STLINE     0x01
+#define HC_F_RES_HDR        0x02
+#define HC_F_RES_BODY       0x04
+#define HC_F_RES_END        0x08
+
+
 #endif /* ! _HAPROXY_HTTCLIENT__T_H */
index c3e5addeb83e91e88fa8dbe7297e4c1f8c796a93..b3366406472b954e430a8eba671c724e2e9e8130 100644 (file)
@@ -59,12 +59,6 @@ static char *resolvers_prefer = NULL;
  * The functions will be  starting by "hc_cli" for "httpclient cli"
  */
 
-/* What kind of data we need to read */
-#define HC_CLI_F_RES_STLINE     0x01
-#define HC_CLI_F_RES_HDR        0x02
-#define        HC_CLI_F_RES_BODY       0x04
-#define HC_CLI_F_RES_END        0x08
-
 /* the CLI context for the httpclient command */
 struct hcli_svc_ctx {
        struct httpclient *hc;  /* the httpclient instance */
@@ -83,7 +77,7 @@ void hc_cli_res_stline_cb(struct httpclient *hc)
                return;
 
        ctx = appctx->svcctx;
-       ctx->flags |= HC_CLI_F_RES_STLINE;
+       ctx->flags |= HC_F_RES_STLINE;
        appctx_wakeup(appctx);
 }
 
@@ -96,7 +90,7 @@ void hc_cli_res_headers_cb(struct httpclient *hc)
                return;
 
        ctx = appctx->svcctx;
-       ctx->flags |= HC_CLI_F_RES_HDR;
+       ctx->flags |= HC_F_RES_HDR;
        appctx_wakeup(appctx);
 }
 
@@ -109,7 +103,7 @@ void hc_cli_res_body_cb(struct httpclient *hc)
                return;
 
        ctx = appctx->svcctx;
-       ctx->flags |= HC_CLI_F_RES_BODY;
+       ctx->flags |= HC_F_RES_BODY;
        appctx_wakeup(appctx);
 }
 
@@ -122,7 +116,7 @@ void hc_cli_res_end_cb(struct httpclient *hc)
                return;
 
        ctx = appctx->svcctx;
-       ctx->flags |= HC_CLI_F_RES_END;
+       ctx->flags |= HC_F_RES_END;
        appctx_wakeup(appctx);
 }
 
@@ -197,15 +191,15 @@ static int hc_cli_io_handler(struct appctx *appctx)
        struct httpclient *hc = ctx->hc;
        struct http_hdr *hdrs, *hdr;
 
-       if (ctx->flags & HC_CLI_F_RES_STLINE) {
+       if (ctx->flags & HC_F_RES_STLINE) {
                chunk_printf(&trash, "%.*s %d %.*s\n", (unsigned int)istlen(hc->res.vsn), istptr(hc->res.vsn),
                             hc->res.status, (unsigned int)istlen(hc->res.reason), istptr(hc->res.reason));
                if (applet_putchk(appctx, &trash) == -1)
                        goto more;
-               ctx->flags &= ~HC_CLI_F_RES_STLINE;
+               ctx->flags &= ~HC_F_RES_STLINE;
        }
 
-       if (ctx->flags & HC_CLI_F_RES_HDR) {
+       if (ctx->flags & HC_F_RES_HDR) {
                chunk_reset(&trash);
                hdrs = hc->res.hdrs;
                for (hdr = hdrs; isttest(hdr->v); hdr++) {
@@ -216,10 +210,10 @@ static int hc_cli_io_handler(struct appctx *appctx)
                        goto too_many_hdrs;
                if (applet_putchk(appctx, &trash) == -1)
                        goto more;
-               ctx->flags &= ~HC_CLI_F_RES_HDR;
+               ctx->flags &= ~HC_F_RES_HDR;
        }
 
-       if (ctx->flags & HC_CLI_F_RES_BODY) {
+       if (ctx->flags & HC_F_RES_BODY) {
                int ret;
 
                ret = httpclient_res_xfer(hc, sc_ib(sc));
@@ -228,12 +222,12 @@ static int hc_cli_io_handler(struct appctx *appctx)
                /* remove the flag if the buffer was emptied */
                if (httpclient_data(hc))
                        goto more;
-               ctx->flags &= ~HC_CLI_F_RES_BODY;
+               ctx->flags &= ~HC_F_RES_BODY;
        }
 
        /* we must close only if F_END is the last flag */
-       if (ctx->flags ==  HC_CLI_F_RES_END) {
-               ctx->flags &= ~HC_CLI_F_RES_END;
+       if (ctx->flags ==  HC_F_RES_END) {
+               ctx->flags &= ~HC_F_RES_END;
                goto end;
        }