1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-17 20:32:41 +01:00

Minor improvements to handling Aphlict status code

Summary: Self explanatory.

Test Plan: `curl`ed a few URLs.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: Korvin, epriestley

Differential Revision: https://secure.phabricator.com/D11147
This commit is contained in:
Joshua Spence 2015-01-03 09:11:08 +11:00
parent 9f31e023f4
commit 87f11a091d

View file

@ -206,23 +206,20 @@ http.createServer(function(request, response) {
'<%s> Internal Server Error! %s', '<%s> Internal Server Error! %s',
request.socket.remoteAddress, request.socket.remoteAddress,
err); err);
response.statusCode = 500; response.writeHead(500, 'Internal Server Error');
response.write('500 Internal Server Error\n');
} }
} catch (err) { } catch (err) {
debug.log( debug.log(
'<%s> Bad Request! %s', '<%s> Bad Request! %s',
request.socket.remoteAddress, request.socket.remoteAddress,
err); err);
response.statusCode = 400; response.writeHead(400, 'Bad Request');
response.write('400 Bad Request\n');
} finally { } finally {
response.end(); response.end();
} }
}); });
} else { } else {
response.statusCode = 405; response.writeHead(405, 'Method Not Allowed');
response.write('405 Method Not Allowed\n');
response.end(); response.end();
} }
} else if (request.url == '/status/') { } else if (request.url == '/status/') {
@ -240,8 +237,7 @@ http.createServer(function(request, response) {
response.write(JSON.stringify(status)); response.write(JSON.stringify(status));
response.end(); response.end();
} else { } else {
response.statusCode = 404; response.writeHead(404, 'Not Found');
response.write('404 Not Found\n');
response.end(); response.end();
} }
}).listen(config.admin, config.host); }).listen(config.admin, config.host);