]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: cache/htx: Return only the headers of cached objects to HEAD requests
authorChristopher Faulet <cfaulet@haproxy.com>
Mon, 25 Feb 2019 10:08:34 +0000 (11:08 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Tue, 26 Feb 2019 13:04:23 +0000 (14:04 +0100)
The body of a cached object must not be sent in response to a HEAD request. This
works for the legacy HTTP because the parsing is performed by HTTP analyzers
_AND_ because the connection is closed at the end of the transaction. So the
body is ignored. But the applet send it. For the HTX, the applet must skip the
body explicitly.

This patch must be backported to 1.9.

src/cache.c

index f1ad3c7e2cf857d26d3db50fbd38efcb925f05b0..fddff72c312e95f105fe8783d74f40de10987971 100644 (file)
@@ -1023,7 +1023,11 @@ static void htx_cache_io_handler(struct appctx *appctx)
                        goto error;
 
                total += ret;
-               if (cache_ptr->data_len)
+               if (si_strm(si)->txn->meth == HTTP_METH_HEAD) {
+                       /* Skip response body for HEAD requests */
+                       appctx->st0 = HTX_CACHE_EOM;
+               }
+               else if (cache_ptr->data_len)
                        appctx->st0 = HTX_CACHE_DATA;
                else if (first->len > sizeof(*cache_ptr) + appctx->ctx.cache.sent) {
                        /* Headers have benn sent (hrds_len) and there is no data