From 64554a55f483a0fae62e2636aeb029f786a7a8c6 Mon Sep 17 00:00:00 2001 From: Christopher Faulet Date: Thu, 31 Oct 2024 14:16:01 +0100 Subject: [PATCH] MINOR: stream: Add http-buffer-request option in the waiting entities When http-buffer-request option is set on a proxy, the processing will be paused to wait the full request payload or a full buffer. So it is an entity that block the processing, just like a rule or a filter that yields. So now, it is reported as a waiting entity if an error or a timeout occurred. To do so, an stream entity type is added for this option. There is no pointer. And "waiting_entity" sample fetch returns the option name. --- include/haproxy/stream-t.h | 7 ++++--- src/http_ana.c | 4 ++++ src/stream.c | 6 ++++++ 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/include/haproxy/stream-t.h b/include/haproxy/stream-t.h index 0921cf0aa..5da8101ed 100644 --- a/include/haproxy/stream-t.h +++ b/include/haproxy/stream-t.h @@ -161,9 +161,10 @@ enum { * depending on the context; */ enum { - STRM_ENTITY_NONE = 0x0000, - STRM_ENTITY_RULE = 0x0001, - STRM_ENTITY_FILTER = 0x0002, + STRM_ENTITY_NONE = 0x0000, + STRM_ENTITY_RULE = 0x0001, + STRM_ENTITY_FILTER = 0x0002, + STRM_ENTITY_WREQ_BODY = 0x0003, }; /* This function is used to report flags in debugging tools. Please reflect diff --git a/src/http_ana.c b/src/http_ana.c index 05bc92383..ecf417e5a 100644 --- a/src/http_ana.c +++ b/src/http_ana.c @@ -826,8 +826,12 @@ int http_wait_for_request_body(struct stream *s, struct channel *req, int an_bit switch (http_wait_for_msg_body(s, req, s->be->timeout.httpreq, 0)) { case HTTP_RULE_RES_CONT: + s->waiting_entity.type = STRM_ENTITY_NONE; + s->waiting_entity.ptr = NULL; goto http_end; case HTTP_RULE_RES_YIELD: + s->waiting_entity.type = STRM_ENTITY_WREQ_BODY; + s->waiting_entity.ptr = NULL; goto missing_data_or_waiting; case HTTP_RULE_RES_BADREQ: goto return_bad_req; diff --git a/src/stream.c b/src/stream.c index e1a464971..d6184aae0 100644 --- a/src/stream.c +++ b/src/stream.c @@ -4189,6 +4189,12 @@ static int smp_fetch_waiting_entity(const struct arg *args, struct sample *smp, smp->data.u.str = *trash; } } + else if (smp->strm->waiting_entity.type == STRM_ENTITY_WREQ_BODY) { + struct buffer *trash = get_trash_chunk(); + + chunk_memcat(trash, "http-buffer-request", 19); + smp->data.u.str = *trash; + } else return 0;