]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: http_ext/7239: warn the user when fetch is not available
authorAurelien DARRAGON <adarragon@haproxy.com>
Fri, 6 Jan 2023 14:06:49 +0000 (15:06 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Fri, 27 Jan 2023 14:18:59 +0000 (15:18 +0100)
http option forwarded (rfc7239) supports sample expressions when
configuring 'host', 'for' and 'by' parameters.

However, since we are in a http-backend-only context, right after http
header is processed, we have a limited resolution scope for the sample
expression provided by the user.

To prevent any confusion, a warning is emitted when parsing the option
if the user relies on a sample expression (more precisely a fetch) which
would yield unexpected results at runtime when processing the option.

src/http_ext.c

index 4a9a0b091a6ec2258a51a82027749e0faa4a5c6c..f2e3781c5994485647eaf4d779d8fe7671fbba56 100644 (file)
@@ -1143,6 +1143,19 @@ int proxy_http_compile_7239(struct proxy *curproxy)
                        ha_free(&err);
                        cfgerr++;
                }
+               else if (!(cur_expr->fetch->val & SMP_VAL_BE_HRQ_HDR)) {
+                       /* fetch not available in this context: sample expr is resolved
+                        * within backend right after headers are processed.
+                        * (in http_process_request())
+                        * -> we simply warn the user about the misuse
+                        */
+                       ha_warning("%s '%s' [%s:%d]: in 'option forwarded' sample expression '%s' : "
+                                  "some args extract information from '%s', "
+                                  "none of which is available here.\n",
+                                  proxy_type_str(curproxy), curproxy->id,
+                                  curproxy->http.fwd.c_file, curproxy->http.fwd.c_line,
+                                  *expr_str, sample_ckp_names(cur_expr->fetch->use));
+               }
                /* post parsing individual expr cleanup */
                ha_free(expr_str);