]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: http-act: Use the good message to test strict rewritting mode
authorChristopher Faulet <cfaulet@haproxy.com>
Fri, 24 Jan 2020 14:37:13 +0000 (15:37 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Thu, 6 Feb 2020 08:36:36 +0000 (09:36 +0100)
Since the strict rewritting mode was introduced, actions manipulating headers
(set/add/replace) always rely on the request message to test if the
HTTP_MSGF_SOFT_RW flag is set or not. But, of course, we must only rely on the
request for http-request rules. For http-response rules, we must use the
response message.

This patch must be backported if the strict rewritting is backported too.

src/http_act.c

index 163213099e378be12f260017c04eed344b15e486..e1d9c96bd803684ac9bb972b711c7e26b799cb76 100644 (file)
@@ -1142,7 +1142,8 @@ static enum act_return http_action_early_hint(struct act_rule *rule, struct prox
 static enum act_return http_action_set_header(struct act_rule *rule, struct proxy *px,
                                              struct session *sess, struct stream *s, int flags)
 {
-       struct htx *htx = htxbuf((rule->from == ACT_F_HTTP_REQ) ? &s->req.buf : &s->res.buf);
+       struct http_msg *msg = ((rule->from == ACT_F_HTTP_REQ) ? &s->txn->req : &s->txn->rsp);
+       struct htx *htx = htxbuf(&msg->chn->buf);
        enum act_return ret = ACT_RET_CONT;
        struct buffer *replace;
        struct http_hdr_ctx ctx;
@@ -1186,7 +1187,7 @@ static enum act_return http_action_set_header(struct act_rule *rule, struct prox
        if (objt_server(s->target))
                _HA_ATOMIC_ADD(&__objt_server(s->target)->counters.failed_rewrites, 1);
 
-       if (!(s->txn->req.flags & HTTP_MSGF_SOFT_RW))
+       if (!(msg->flags & HTTP_MSGF_SOFT_RW))
                ret = ACT_RET_ERR;
        goto leave;
 }
@@ -1261,7 +1262,8 @@ static enum act_parse_ret parse_http_set_header(const char **args, int *orig_arg
 static enum act_return http_action_replace_header(struct act_rule *rule, struct proxy *px,
                                                  struct session *sess, struct stream *s, int flags)
 {
-       struct htx *htx = htxbuf((rule->from == ACT_F_HTTP_REQ) ? &s->req.buf : &s->res.buf);
+       struct http_msg *msg = ((rule->from == ACT_F_HTTP_REQ) ? &s->txn->req : &s->txn->rsp);
+       struct htx *htx = htxbuf(&msg->chn->buf);
        enum act_return ret = ACT_RET_CONT;
        struct buffer *replace;
        int r;
@@ -1295,7 +1297,7 @@ static enum act_return http_action_replace_header(struct act_rule *rule, struct
        if (objt_server(s->target))
                _HA_ATOMIC_ADD(&__objt_server(s->target)->counters.failed_rewrites, 1);
 
-       if (!(s->txn->req.flags & HTTP_MSGF_SOFT_RW))
+       if (!(msg->flags & HTTP_MSGF_SOFT_RW))
                ret = ACT_RET_ERR;
        goto leave;
 }