From: Christian Hofstaedtler Date: Fri, 25 Jul 2014 14:02:35 +0000 (+0200) Subject: web: Fix HEAD body and Content-Length X-Git-Tag: auth-3.4.0-rc1~21^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=ac9908c20c0afbeee396a989bf2248ef96a109d0;p=thirdparty%2Fpdns.git 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. --- 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; }