# HG changeset patch # User John "Elwin" Edwards # Date 1338952427 25200 # Node ID 57f4b36ef06b33d039d67e78f3a6f5faa14822dc # Parent 23a495e8172551cbb99722beb10b78e129f05d33 rlgwebd.js: handle HTTP HEAD properly. Prevent a message body from being sent in response to HTTP HEAD. diff -r 23a495e81725 -r 57f4b36ef06b rlgwebd.js --- a/rlgwebd.js Tue Jun 05 14:55:33 2012 -0700 +++ b/rlgwebd.js Tue Jun 05 20:13:47 2012 -0700 @@ -518,14 +518,18 @@ } else { res.writeHead(200, resheaders); - res.write(data); + if (req.method != 'HEAD') + res.write(data); res.end(); } }); } else { res.writeHead(404, resheaders); - res.write("" + nname + "\n

" + nname + " Not Found

\n"); + if (req.method != 'HEAD') { + res.write("" + nname + "\n

" + + nname + " Not Found

\n"); + } res.end(); } }); @@ -573,7 +577,8 @@ } } res.writeHead(200, { "Content-Type": "application/json" }); - res.write(JSON.stringify(reply)); + if (req.method != 'HEAD') + res.write(JSON.stringify(reply)); res.end(); } @@ -609,7 +614,6 @@ /* This will send the response once the whole request is here. */ function respond() { - //formdata = getFormValues(reqbody); formdata = getMsg(reqbody); var target = url.parse(req.url).pathname; var cterm = findTermSession(formdata); @@ -650,6 +654,11 @@ } else if (req.method == 'GET' || req.method == 'HEAD') { if (target == '/feed') { + if (req.method == 'HEAD') { + res.writeHead(200, {"Content-Type": "application/json"}); + res.end(); + return; + } if (!cterm) { sendError(res, 1, null); return;