From: William Lallemand Date: Fri, 24 Jan 2025 16:53:04 +0000 (+0100) Subject: BUG/MINOR: httpclient: wrongly named httpproxy flag X-Git-Tag: v3.0.12~99 X-Git-Url: http://git.haproxy.org/?a=commitdiff_plain;h=129d550679d544d6450896a35e11c8dfdc984d8e;p=haproxy-3.0.git BUG/MINOR: httpclient: wrongly named httpproxy flag The HC_F_HTTPPROXY flag was wrongly named and does not use the correct value, indeed this flag was meant to be used for the httpclient API, not the httpclient CLI. This patch fixes the problem by introducing HTTPCLIENT_FO_HTTPPROXY which has must be set in hc->flags. Also add a member 'options' in the httpclient structure, because the member flags is reinitialized when starting. Must be backported as far as 3.0. (cherry picked from commit 519abefb57da1ae21fc557213cae8b21cdaa2797) Signed-off-by: Willy Tarreau (cherry picked from commit 008045a03eeca63712546e030a4549671d00ffc1) Signed-off-by: Christopher Faulet (cherry picked from commit cba2b004accf766a3c6e6aac35852e27cd74cf07) Signed-off-by: Christopher Faulet --- diff --git a/include/haproxy/http_client-t.h b/include/haproxy/http_client-t.h index 2c07f77..350a301 100644 --- a/include/haproxy/http_client-t.h +++ b/include/haproxy/http_client-t.h @@ -32,6 +32,7 @@ struct httpclient { int timeout_server; /* server timeout in ms */ void *caller; /* ptr of the caller */ unsigned int flags; /* other flags */ + unsigned int options; /* options */ struct proxy *px; /* proxy for special cases */ struct server *srv_raw; /* server for clear connections */ #ifdef USE_OPENSSL @@ -47,6 +48,9 @@ struct httpclient { #define HTTPCLIENT_FS_STARTED 0x00010000 /* the httpclient was started */ #define HTTPCLIENT_FS_ENDED 0x00020000 /* the httpclient is stopped */ +/* options */ +#define HTTPCLIENT_O_HTTPPROXY 0x00000001 /* the request must be use an absolute URI */ + /* States of the HTTP Client Appctx */ enum { HTTPCLIENT_S_REQ = 0, @@ -59,12 +63,12 @@ enum { #define HTTPCLIENT_USERAGENT "HAProxy" -/* What kind of data we need to read */ +/* What kind of data we need to read */ +/* flags meant for the httpclient CLI API */ #define HC_F_RES_STLINE 0x01 #define HC_F_RES_HDR 0x02 #define HC_F_RES_BODY 0x04 #define HC_F_RES_END 0x08 -#define HC_F_HTTPPROXY 0x10 #endif /* ! _HAPROXY_HTTCLIENT__T_H */ diff --git a/src/http_client.c b/src/http_client.c index 7fc6cda..04782a1 100644 --- a/src/http_client.c +++ b/src/http_client.c @@ -281,7 +281,7 @@ int httpclient_req_gen(struct httpclient *hc, const struct ist url, enum http_me int i; int foundhost = 0, foundaccept = 0, foundua = 0; - if (!(hc->flags & HC_F_HTTPPROXY)) + if (!(hc->options & HTTPCLIENT_O_HTTPPROXY)) flags |= HTX_SL_F_NORMALIZED_URI; if (!b_alloc(&hc->req.buf, DB_CHANNEL)) diff --git a/src/ssl_ocsp.c b/src/ssl_ocsp.c index 7d3a485..9f79491 100644 --- a/src/ssl_ocsp.c +++ b/src/ssl_ocsp.c @@ -1299,7 +1299,7 @@ static struct task *ssl_ocsp_update_responses(struct task *task, void *context, /* if the ocsp_update.http_proxy option was set */ if (ocsp_update_dst) { - hc->flags |= HC_F_HTTPPROXY; + hc->options |= HTTPCLIENT_O_HTTPPROXY; if (!sockaddr_alloc(&hc->dst, ocsp_update_dst, sizeof(*ocsp_update_dst))) { ha_alert("ocsp-update: Failed to allocate sockaddr in %s:%d.\n", __FUNCTION__, __LINE__); goto leave;