rlgwebd.js: handle HTTP HEAD properly.
Prevent a message body from being sent in response to HTTP HEAD.
This commit is contained in:
parent
44ccfd87a3
commit
dec7bc108a
1 changed files with 13 additions and 4 deletions
13
rlgwebd.js
13
rlgwebd.js
|
|
@ -518,6 +518,7 @@ function serveStatic(req, res, fname) {
|
|||
}
|
||||
else {
|
||||
res.writeHead(200, resheaders);
|
||||
if (req.method != 'HEAD')
|
||||
res.write(data);
|
||||
res.end();
|
||||
}
|
||||
|
|
@ -525,7 +526,10 @@ function serveStatic(req, res, fname) {
|
|||
}
|
||||
else {
|
||||
res.writeHead(404, resheaders);
|
||||
res.write("<html><head><title>" + nname + "</title></head>\n<body><h1>" + nname + " Not Found</h1></body></html>\n");
|
||||
if (req.method != 'HEAD') {
|
||||
res.write("<html><head><title>" + nname + "</title></head>\n<body><h1>"
|
||||
+ nname + " Not Found</h1></body></html>\n");
|
||||
}
|
||||
res.end();
|
||||
}
|
||||
});
|
||||
|
|
@ -573,6 +577,7 @@ function statusmsg(req, res) {
|
|||
}
|
||||
}
|
||||
res.writeHead(200, { "Content-Type": "application/json" });
|
||||
if (req.method != 'HEAD')
|
||||
res.write(JSON.stringify(reply));
|
||||
res.end();
|
||||
}
|
||||
|
|
@ -609,7 +614,6 @@ function webHandler(req, res) {
|
|||
|
||||
/* 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 @@ function webHandler(req, res) {
|
|||
}
|
||||
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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue