From ac9908c20c0afbeee396a989bf2248ef96a109d0 Mon Sep 17 00:00:00 2001 From: Christian Hofstaedtler Date: Fri, 25 Jul 2014 16:02:35 +0200 Subject: [PATCH] web: Fix HEAD body and Content-Length For HEAD requests, we MUST throw away the body, for all other requests we SHOULD return a Content-Length. --- pdns/webserver.cc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pdns/webserver.cc b/pdns/webserver.cc index 0e56af580a..61300cf41e 100644 --- a/pdns/webserver.cc +++ b/pdns/webserver.cc @@ -215,6 +215,12 @@ HttpResponse WebServer::handleRequest(HttpRequest req) resp.headers["Server"] = "PowerDNS/"VERSION; resp.headers["Connection"] = "close"; + if (req.method == "HEAD") { + resp.body = ""; + } else { + resp.headers["Content-Length"] = lexical_cast(resp.body.size()); + } + return resp; } -- 2.47.2