From 67dcb4ee39b76be225ad0a432d38dd45bbba9ed7 Mon Sep 17 00:00:00 2001 From: Fengda HUANG Date: Mon, 14 Dec 2015 13:40:32 +0800 Subject: [PATCH] fix status code error --- modules/coap.js | 6 +++--- test/server/coap_spec.js | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/modules/coap.js b/modules/coap.js index 9f956eb..9b37796 100644 --- a/modules/coap.js +++ b/modules/coap.js @@ -8,7 +8,7 @@ module.exports = function (app) { var deviceRex = /^\/(.*)\/(.*)\?/; var other = function () { - res.code = '4.00'; + res.code = '4.05'; res.end(JSON.stringify({method: 'not support'})); }; @@ -55,7 +55,7 @@ module.exports = function (app) { var handPut = function () { if (!(deviceRex.test(req.url))) { - res.code = '4.03'; + res.code = '4.04'; res.end(JSON.stringify({topic: 'no exist'})); } var successCB = function (user) { @@ -64,7 +64,7 @@ module.exports = function (app) { payload[deviceID] = deviceRex.exec(req.url)[2]; db.update(payload); - res.code = '2.00'; + res.code = '2.01'; res.end(JSON.stringify({method: 'PUT'})); }; diff --git a/test/server/coap_spec.js b/test/server/coap_spec.js index 4c7be30..9144563 100644 --- a/test/server/coap_spec.js +++ b/test/server/coap_spec.js @@ -53,7 +53,7 @@ describe('CoAP Services Test', function () { var req = coap.request('coap://localhost/hello'); req.on('response', function (res) { - if (res.code === '4.00') { + if (res.code === '4.05') { done(); } }); @@ -216,7 +216,7 @@ describe('CoAP Services Test', function () { var req = request({hostname: 'localhost', port: 5683, pathname: 'device/2', method: 'PUT', query: 'phodal:phodal'}); req.write(JSON.stringify({topic: "this is device UPDATE"})); req.on('response', function (res) { - if (res.code === '2.00') { + if (res.code === '2.01') { done(); } });