]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
web: Fix HEAD body and Content-Length 1633/head
authorChristian Hofstaedtler <christian@hofstaedtler.name>
Fri, 25 Jul 2014 14:02:35 +0000 (16:02 +0200)
committerChristian Hofstaedtler <christian@hofstaedtler.name>
Fri, 25 Jul 2014 14:03:50 +0000 (16:03 +0200)
For HEAD requests, we MUST throw away the body, for all other
requests we SHOULD return a Content-Length.

pdns/webserver.cc

index 0e56af580aa90e2c2cdb6b4aa801d6296b762006..61300cf41ee14fed00eda13a8c956d16c84b8eb4 100644 (file)
@@ -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<string>(resp.body.size());
+  }
+
   return resp;
 }