allow only GET + HEAD requests

This commit is contained in:
jomo 2015-01-02 22:25:09 +01:00
parent 846b738226
commit 0a4011abc1

View File

@ -48,7 +48,7 @@ function requestHandler(req, res) {
var local_path = request.url.pathname.split("/")[1];
console.log(request.method + " " + request.url.pathname);
if (request.method == "GET" || request.method == "HEAD") {
try {
switch (local_path) {
case "":
@ -74,6 +74,12 @@ function requestHandler(req, res) {
});
res.end(config.debug_enabled ? error : "Internal server error");
}
} else {
res.writeHead(405, {
"Content-Type": "text/plain"
});
res.end("Method not allowed");
}
}
http.createServer(requestHandler).listen(process.env.PORT || 3000);