BUG/MEDIUM: compression: handle rewrite errors when updating response headers

When an HTTP response is compressed by HAProxy, the headers are updated.
However it is possible to encounter a rewrite error because the buffer is
full. In this case, the compression is aborted. Thus, we must be sure to
leave the response in a valid state.

For now, it is an issue because the "Content-Encoding" header is added
before all other headers manipulations. So if the compression is aborted on
error, the "Content-Encoding" header may remain while the payload is not
compressed.

So now, we take care to leave with a valid response on error by reordering
the headers manipulations. It is too painful to really rollback all changes,
especially for an edge case.

This patch should be backported as far as 2.0. Note that on the 2.0, the
legacy HTTP part is also concerned.

(cherry picked from commit 910b7577bce977ee08068f22df7a5d824ae4155c)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit 126f683a2c18a3908031a14d1e24ae5e365f223b)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit af0ccbeed1d03da911b7a62aa47d6b756aa6ba32)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
1 file changed