From cb5b748ff157deaafa57cf7ac251c136ac25af37 Mon Sep 17 00:00:00 2001 From: Tom Smeding Date: Thu, 11 Jun 2020 22:32:50 +0200 Subject: server: res.sendStatus already closes the connection, don't do that --- server/serverstore.js | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/server/serverstore.js b/server/serverstore.js index 745877f..430194b 100755 --- a/server/serverstore.js +++ b/server/serverstore.js @@ -69,7 +69,7 @@ app.get("/ss/challenge",function(req,res){ app.param("userid",function(req,res,next,userid){ var password=Persist.getItemSync("user_"+userid); if(!password){ - res.sendStatus(404); + res.status(404); res.end("Non-existent userid"); return; } @@ -82,7 +82,7 @@ app.param("authhash",function(req,res,next,authhash){ hasher.update(s); var hashres=hasher.digest("hex"); if(hashres!=authhash){ - res.sendStatus(403); + res.status(403); res.end("Invalid answer to challenge"); return; } @@ -117,7 +117,7 @@ app.post("/ss/image/:userid/:authhash/:fname",function(req,res){ } } - res.sendStatus(500); + res.status(500); res.end(); }); @@ -129,31 +129,28 @@ app.param("reguserid",function(req,res,next,reguserid){ app.post("/ss/registerx/:reguserid",function(req,res){ //pass password in body var password=req.body; if(Persist.getItemSync("user_"+req.ssreguserid)){ - res.sendStatus(409); //Conflict + res.status(409); //Conflict res.end("That userid already exists"); return; } Persist.setItemSync("user_"+req.ssreguserid,password); res.sendStatus(200); - res.end(); }); app.get("/ss/exists/:reguserid",function(req,res){ res.sendStatus(Persist.getItemSync("user_"+req.ssreguserid)?200:404); - res.end(); }); app.get("/ss/checklogin/:userid/:authhash",function(req,res){ res.sendStatus(200); //login checking is done in the authhash param - res.end(); }); app.param("ssimgcode",function(req,res,next,ssimgcode){ req.ssimgcode=ssimgcode.replace(/[^a-zA-Z0-9]/g,""); if(req.ssimgcode.length!=6){ - res.sendStatus(404); + res.status(404); res.end("Invalid or unknown image code"); return; } @@ -162,14 +159,14 @@ app.param("ssimgcode",function(req,res,next,ssimgcode){ app.get("/ss/get/:userid/:ssimgcode",function(req,res){ var files=glob.sync(__dirname+"/images/"+req.ssuser[0]+"/"+req.ssimgcode+"*"); if(files.length==0){ - res.sendStatus(404); + res.status(404); res.end("Unknown image code"); return; } if(files.length>1){ console.log("More than one file matched; internal error"); console.log(files); - res.sendStatus(500); + res.status(500); res.end("More than one file matched; internal error"); return; } -- cgit v1.2.3-70-g09d2