From: Christopher Faulet Date: Fri, 24 Jan 2020 14:37:13 +0000 (+0100) Subject: BUG/MINOR: http-act: Use the good message to test strict rewritting mode X-Git-Tag: v2.2-dev2~32 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=91e31d83c989bdc579b76467c51f7fbe18908e54;p=thirdparty%2Fhaproxy.git BUG/MINOR: http-act: Use the good message to test strict rewritting mode 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. --- diff --git a/src/http_act.c b/src/http_act.c index 163213099e..e1d9c96bd8 100644 --- a/src/http_act.c +++ b/src/http_act.c @@ -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; }