From 112991af6c80b90b608106ebee269bd05e4a94ed Mon Sep 17 00:00:00 2001 From: "Jason J. Gullickson" Date: Sat, 3 Jan 2015 01:35:29 -0600 Subject: [PATCH] added support for HEAD request, but curl hangs for some reason, so investigating --- jsfs2.js | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/jsfs2.js b/jsfs2.js index 7a7721a..5902a01 100644 --- a/jsfs2.js +++ b/jsfs2.js @@ -370,6 +370,27 @@ http.createServer(function(req, res){ break; + case "HEAD": + + if(typeof stored_files[target_url] != "undefined"){ + var requested_file = stored_files[target_url]; + if(!requested_file.private || (requested_file.access_token === access_token)){ + res.writeHead(200,{ + "Content-Type": requested_file.content_type, + "Content-Length": requested_file.file_size + }); + res.end(); + } else { + res.statusCode = 401; + res.end(); + } + } else { + res.statusCode = 404; + res.end(); + } + + break; + case "OPTIONS": // support for OPTIONS is required to support cross-domain requests (CORS)