]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MEDIUM: http: remove content-length form responses with bad transfer-encoding
authorWilly Tarreau <w@1wt.eu>
Fri, 1 May 2015 08:25:45 +0000 (10:25 +0200)
committerWilly Tarreau <w@1wt.eu>
Fri, 1 May 2015 11:56:11 +0000 (13:56 +0200)
The spec mandates that content-length must be removed from messages if
Transfer-Encoding is present, not just for valid ones.

This must be backported to 1.5 and 1.4.

src/proto_http.c

index ad075a49f7663597f5ed2831ccade5e264107b87..a34c11036a172300f8fe221390d9e6fec90fa0b3 100644 (file)
@@ -6235,12 +6235,11 @@ int http_wait_for_response(struct stream *s, struct channel *rep, int an_bit)
 
        /* Chunked responses must have their content-length removed */
        ctx.idx = 0;
-       if (msg->flags & HTTP_MSGF_TE_CHNK) {
+       if (use_close_only || (msg->flags & HTTP_MSGF_TE_CHNK)) {
                while (http_find_header2("Content-Length", 14, rep->buf->p, &txn->hdr_idx, &ctx))
                        http_remove_header2(msg, &txn->hdr_idx, &ctx);
        }
-       else while (!use_close_only &&
-              http_find_header2("Content-Length", 14, rep->buf->p, &txn->hdr_idx, &ctx)) {
+       else while (http_find_header2("Content-Length", 14, rep->buf->p, &txn->hdr_idx, &ctx)) {
                signed long long cl;
 
                if (!ctx.vlen) {