MINOR: http-rules: Add a flag on redirect rules to know the rule direction

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.

(cherry picked from commit c87e46881687b8ddb9b3f459e60edb1e8d7c5d7c)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit 7351c78970ccbf828dc4db2e0ff9bbe02ab3e194)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
diff --git a/include/types/proto_http.h b/include/types/proto_http.h
index d4fa652..f7bb364 100644
--- a/include/types/proto_http.h
+++ b/include/types/proto_http.h
@@ -155,6 +155,7 @@
 	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 ) */
diff --git a/src/http_rules.c b/src/http_rules.c
index 7eb20c4..2ac11fe 100644
--- a/src/http_rules.c
+++ b/src/http_rules.c
@@ -1037,7 +1037,7 @@
 	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;