diff --git a/include/haproxy/htx.h b/include/haproxy/htx.h index 5ede1a3ec..c5e75de3a 100644 --- a/include/haproxy/htx.h +++ b/include/haproxy/htx.h @@ -610,6 +610,19 @@ static inline int htx_copy_msg(struct htx *htx, const struct buffer *msg) return htx_append_msg(htx, htxbuf(msg)); } +static inline void htx_skip_msg_payload(struct htx *htx) +{ + struct htx_blk *blk = htx_get_first_blk(htx); + + while (blk) { + enum htx_blk_type type = htx_get_blk_type(blk); + + blk = ((type > HTX_BLK_EOH && type < HTX_BLK_EOM) + ? htx_remove_blk(htx, blk) + : htx_get_next_blk(htx, blk)); + } +} + /* Returns the number of used blocks in the HTX message <htx>. Note that it is * illegal to call this function with htx == NULL. Note also blocks of type * HTX_BLK_UNUSED are part of used blocks. diff --git a/src/http_ana.c b/src/http_ana.c index 870682ff9..1dd43dcc4 100644 --- a/src/http_ana.c +++ b/src/http_ana.c @@ -4575,6 +4575,9 @@ int http_forward_proxy_resp(struct stream *s, int final) if (!http_eval_after_res_rules(s)) return 0; + if (s->txn->meth == HTTP_METH_HEAD) + htx_skip_msg_payload(htx); + channel_auto_read(req); channel_abort(req); channel_auto_close(req);