From: William Lallemand Date: Tue, 21 Sep 2021 08:45:34 +0000 (+0200) Subject: MINOR: httpclient: httpclient_data() returns the available data X-Git-Tag: v2.5-dev8~6 X-Git-Url: http://git.haproxy.org/?a=commitdiff_plain;h=518878e007aa7cdb6b3d0047427089733bba23e1;p=haproxy-2.5.git MINOR: httpclient: httpclient_data() returns the available data httpclient_data() returns the available data in the httpclient. --- diff --git a/include/haproxy/http_client.h b/include/haproxy/http_client.h index a34b3cd..af7a17e 100644 --- a/include/haproxy/http_client.h +++ b/include/haproxy/http_client.h @@ -10,4 +10,11 @@ struct appctx *httpclient_start(struct httpclient *hc); int httpclient_res_xfer(struct httpclient *hc, struct buffer *dst); int httpclient_req_gen(struct httpclient *hc, const struct ist url, enum http_meth_t meth, const struct http_hdr *hdrs); + +/* Return the amount of data available in the httpclient response buffer */ +static inline int httpclient_data(struct httpclient *hc) +{ + return b_data(&hc->res.buf); +} + #endif /* ! _HAPROXY_HTTCLIENT_H */ diff --git a/src/http_client.c b/src/http_client.c index 69297e1..d688936 100644 --- a/src/http_client.c +++ b/src/http_client.c @@ -200,7 +200,7 @@ static int hc_cli_io_handler(struct appctx *appctx) ret = httpclient_res_xfer(hc, &si_ic(si)->buf); channel_add_input(si_ic(si), ret); /* forward what we put in the buffer channel */ - if (!b_data(&hc->res.buf)) {/* remove the flag if the buffer was emptied */ + if (!httpclient_data(hc)) {/* remove the flag if the buffer was emptied */ appctx->ctx.cli.i0 &= ~HC_CLI_F_RES_BODY; } goto out;