mirror of
https://github.com/azures04/crafatar.git
synced 2026-03-21 23:41:18 +01:00
log response ID first for access log
also made sure 'headers' is defined before it's used
This commit is contained in:
parent
a15cb20144
commit
d49f7279b3
@ -26,18 +26,6 @@ var silent_errors = ["ETIMEDOUT", "ESOCKETTIMEDOUT", "ECONNRESET", "EHOSTUNREACH
|
||||
// * hash: image hash, required when body is an image
|
||||
// * err: a possible Error
|
||||
module.exports = function(request, response, result) {
|
||||
response.on("close", function() {
|
||||
logging.warn(request.id, "Connection closed");
|
||||
});
|
||||
|
||||
response.on("finish", function() {
|
||||
logging.log(request.method, request.url.href, request.id, response.statusCode, headers["Response-Time"] + "ms", "(" + (human_status[result.status] || "-") + ")");
|
||||
});
|
||||
|
||||
response.on("error", function(err) {
|
||||
logging.error(request.id, err);
|
||||
});
|
||||
|
||||
// These headers are the same for every response
|
||||
var headers = {
|
||||
"Content-Type": result.body && result.type || "text/plain",
|
||||
@ -47,6 +35,18 @@ module.exports = function(request, response, result) {
|
||||
"Access-Control-Allow-Origin": "*"
|
||||
};
|
||||
|
||||
response.on("close", function() {
|
||||
logging.warn(request.id, "Connection closed");
|
||||
});
|
||||
|
||||
response.on("finish", function() {
|
||||
logging.log(request.id, request.method, request.url.href, response.statusCode, headers["Response-Time"] + "ms", "(" + (human_status[result.status] || "-") + ")");
|
||||
});
|
||||
|
||||
response.on("error", function(err) {
|
||||
logging.error(request.id, err);
|
||||
});
|
||||
|
||||
if (result.err) {
|
||||
var silent = silent_errors.indexOf(result.err.code) !== -1;
|
||||
if (result.err.stack && !silent) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user