From 95e7cf1ddf35676940b105997dfbacfb2065c13a Mon Sep 17 00:00:00 2001 From: Remi Tricot-Le Breton Date: Tue, 20 Dec 2022 11:11:03 +0100 Subject: [PATCH] MINOR: httpclient: Make the CLI flags public for future use 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 | 7 +++++++ src/http_client.c | 30 ++++++++++++------------------ 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/include/haproxy/http_client-t.h b/include/haproxy/http_client-t.h index 3d05c0451..7ae0e612f 100644 --- a/include/haproxy/http_client-t.h +++ b/include/haproxy/http_client-t.h @@ -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 */ diff --git a/src/http_client.c b/src/http_client.c index c3e5addeb..b33664064 100644 --- a/src/http_client.c +++ b/src/http_client.c @@ -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; }