From d0689c9e3bd774ad9c698ec89abe3147e3cf2571 Mon Sep 17 00:00:00 2001 From: jomo Date: Fri, 17 Jul 2015 01:37:26 +0200 Subject: [PATCH 1/2] change two more logs to debug --- lib/cache.js | 2 +- lib/helpers.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/cache.js b/lib/cache.js index f3ac571..1f7a568 100644 --- a/lib/cache.js +++ b/lib/cache.js @@ -138,7 +138,7 @@ exp.save_hash = function(rid, userId, skin_hash, cape_hash, callback) { // removes the hash for +userId+ from the cache exp.remove_hash = function(rid, userId) { - logging.log(rid, "deleting hash from cache"); + logging.debug(rid, "deleting hash from cache"); redis.del(userId.toLowerCase(), "h", "t"); }; diff --git a/lib/helpers.js b/lib/helpers.js index 46384c5..549e35a 100644 --- a/lib/helpers.js +++ b/lib/helpers.js @@ -156,7 +156,7 @@ function resume(userId, type, err, hash) { function store_images(rid, userId, cache_details, type, callback) { var is_uuid = userId.length > 16; if (requests[type][userId]) { - logging.log(rid, "adding to request queue"); + logging.debug(rid, "adding to request queue"); push_request(userId, type, callback); } else { // add request to the queue From 607dcaf6e58769b71d8e7086bc07776491f93945 Mon Sep 17 00:00:00 2001 From: jomo Date: Fri, 17 Jul 2015 10:09:34 +0200 Subject: [PATCH 2/2] use status -2 for 404s human_status (response.js) defines code -2 as 'user error'. 404 is definitely a user error, so using that makes sense. eventually we should change the whole status code thing with #120 --- lib/response.js | 7 ++----- lib/routes/avatars.js | 5 +++-- lib/routes/capes.js | 5 +++-- lib/routes/renders.js | 5 +++-- lib/routes/skins.js | 5 +++-- test/test.js | 2 +- 6 files changed, 15 insertions(+), 14 deletions(-) diff --git a/lib/response.js b/lib/response.js index 648495a..09a703a 100644 --- a/lib/response.js +++ b/lib/response.js @@ -77,11 +77,8 @@ module.exports = function(request, response, result) { return; } - if (result.status === -3) { - response.writeHead(404, headers); - response.end(result.body); - } else if (result.status === -2) { - response.writeHead(422, headers); + if (result.status === -2) { + response.writeHead(result.code || 422, headers); response.end(result.body); } else if (result.status === -1) { response.writeHead(500, headers); diff --git a/lib/routes/avatars.js b/lib/routes/avatars.js index 6a2682e..0d03a22 100644 --- a/lib/routes/avatars.js +++ b/lib/routes/avatars.js @@ -52,8 +52,9 @@ module.exports = function(req, callback) { // check for extra paths if (req.url.path_list.length > 2) { callback({ - status: -3, - body: "Invalid URL Path" + status: -2, + body: "Invalid Path", + code: 404 }); return; } diff --git a/lib/routes/capes.js b/lib/routes/capes.js index ddda379..c3f303d 100644 --- a/lib/routes/capes.js +++ b/lib/routes/capes.js @@ -11,8 +11,9 @@ module.exports = function(req, callback) { // check for extra paths if (req.url.path_list.length > 2) { callback({ - status: -3, - body: "Invalid URL Path" + status: -2, + body: "Invalid Path", + code: 404 }); return; } diff --git a/lib/routes/renders.js b/lib/routes/renders.js index e1508e7..aa3288d 100644 --- a/lib/routes/renders.js +++ b/lib/routes/renders.js @@ -62,8 +62,9 @@ module.exports = function(req, callback) { // check for extra paths if (req.url.path_list.length > 3) { callback({ - status: -3, - body: "Invalid URL Path" + status: -2, + body: "Invalid Path", + code: 404 }); return; } diff --git a/lib/routes/skins.js b/lib/routes/skins.js index f0b8e99..3a245fa 100644 --- a/lib/routes/skins.js +++ b/lib/routes/skins.js @@ -59,8 +59,9 @@ module.exports = function(req, callback) { // check for extra paths if (req.url.path_list.length > 2) { callback({ - status: -3, - body: "Invalid URL Path" + status: -2, + body: "Invalid Path", + code: 404 }); return; } diff --git a/test/test.js b/test/test.js index c45689c..8bfd808 100644 --- a/test/test.js +++ b/test/test.js @@ -859,7 +859,7 @@ describe("Crafatar", function() { }); }); - it("should return a 404 (invalid request path " + location + ")", function(done) { + it("should return a 404 (invalid path " + location + ")", function(done) { request.get("http://localhost:3000/" + location + "/853c80ef3c3749fdaa49938b674adae6/invalid", function(error, res, body) { assert.ifError(error); assert.strictEqual(res.statusCode, 404);