nedap server: all errors are 503 Bad Gateway, Internetkurort

This commit is contained in:
Astro 2011-12-14 17:05:10 +01:00
parent a1b0fbb25e
commit 5602b3ae94
2 changed files with 10 additions and 12 deletions

View File

@ -61,6 +61,12 @@ function updateBackend() {
} }
} }
function errorResponse(res) {
res.writeHead(503, { 'Content-type': MIME_HTML });
res.write("<img src=\"/503.png\">");
res.end();
}
function nedap(app) { function nedap(app) {
app.get('/', function(req, res) { app.get('/', function(req, res) {
if (mode === 'nedap' && if (mode === 'nedap' &&
@ -125,16 +131,10 @@ function nedap(app) {
'Location': '/thanks' }); 'Location': '/thanks' });
res.end(); res.end();
} else { } else {
res.writeHead(400, { 'Content-type': MIME_HTML, errorResponse(res);
'Location': '/' });
res.write(html("<p>Face validation error.</p>"));
res.end();
} }
} else { } else {
res.writeHead(400, { 'Content-type': MIME_HTML, errorResponse(res);
'Location': '/' });
res.write(html("<p>Huh?</p>"));
res.end();
} }
}); });
@ -147,8 +147,7 @@ function nedap(app) {
app.post('/i', function(req, res) { app.post('/i', function(req, res) {
if (req.files.gif) { if (req.files.gif) {
if (!Token.validate(req.body.token)) { if (!Token.validate(req.body.token)) {
res.writeHead(200, { 'Content-type': MIME_HTML }); errorResponse(res);
res.end("Cheater!");
return; return;
} }
/* pass to frontend */ /* pass to frontend */
@ -171,8 +170,7 @@ function nedap(app) {
res.end(); res.end();
} else { } else {
console.error(err.stack || err); console.error(err.stack || err);
res.writeHead(500, { 'Content-type': 'text/plain' }); errorResponse(res);
res.end("Oops");
} }
}); });

BIN
nedap/static/503.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB