From: Christopher Faulet Date: Mon, 25 Feb 2019 10:08:34 +0000 (+0100) Subject: BUG/MINOR: cache/htx: Return only the headers of cached objects to HEAD requests X-Git-Tag: v2.0-dev1~9 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f0dd03745647f91bb4adba1412e51a828cd112bc;p=thirdparty%2Fhaproxy.git BUG/MINOR: cache/htx: Return only the headers of cached objects to HEAD requests 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. --- diff --git a/src/cache.c b/src/cache.c index f1ad3c7e2c..fddff72c31 100644 --- a/src/cache.c +++ b/src/cache.c @@ -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