]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: http-rules: Add a flag on redirect rules to know the rule direction
authorChristopher Faulet <cfaulet@haproxy.com>
Tue, 28 Jan 2020 08:13:41 +0000 (09:13 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Thu, 6 Feb 2020 13:55:34 +0000 (14:55 +0100)
HTTP redirect rules can be evaluated on the request or the response path. So
when a redirect rule is evaluated, it is important to have this information
because some specific processing may be performed depending on the direction. So
the REDIRECT_FLAG_FROM_REQ flag has been added. It is set when applicable on the
redirect rule during the parsing.

This patch is mandatory to fix a bug on redirect rule. It must be backported to
all stable versions.

include/types/http_ana.h
src/http_rules.c

index 5a7ced7b0235089ab56af814ea227ff55ea6f227..bc66098585653c9d3882069202e3262008031b41 100644 (file)
@@ -99,6 +99,7 @@ enum {
        REDIRECT_FLAG_NONE = 0,
        REDIRECT_FLAG_DROP_QS = 1,      /* drop query string */
        REDIRECT_FLAG_APPEND_SLASH = 2, /* append a slash if missing at the end */
+       REDIRECT_FLAG_FROM_REQ = 3,     /* redirect rule on the request path */
 };
 
 /* Redirect types (location, prefix, extended ) */
index 2e70e6bf0f03262c18dededb1bc794a9e05c0c73..f1a187b162a543ae48e921ddcc023bd5fba74136 100644 (file)
@@ -206,7 +206,7 @@ struct redirect_rule *http_parse_redirect_rule(const char *file, int linenum, st
        const char *destination = NULL;
        const char *cookie = NULL;
        int cookie_set = 0;
-       unsigned int flags = REDIRECT_FLAG_NONE;
+       unsigned int flags = (!dir ? REDIRECT_FLAG_FROM_REQ : REDIRECT_FLAG_NONE);
        struct acl_cond *cond = NULL;
 
        cur_arg = 0;