[Pkg-javascript-commits] [node-static] 148/151: Accepts all kind of HTTP methods. Fixes #106 and #109

Tonnerre Lombard tonnerre-guest at moszumanska.debian.org
Tue Jan 7 23:18:04 UTC 2014


This is an automated email from the git hooks/post-receive script.

tonnerre-guest pushed a commit to branch master
in repository node-static.

commit f9717e54effb9b8fe4f829fe5b9c0b49cb04b7a4
Author: Pablo Cantero <pablo at pablocantero.com>
Date:   Sun Oct 20 22:23:31 2013 -0200

    Accepts all kind of HTTP methods. Fixes #106 and #109
---
 lib/node-static.js                   |  6 ------
 test/integration/node-static-test.js | 19 +++++++++++++++++--
 2 files changed, 17 insertions(+), 8 deletions(-)

diff --git a/lib/node-static.js b/lib/node-static.js
index 5f8bd3b..4b19118 100644
--- a/lib/node-static.js
+++ b/lib/node-static.js
@@ -133,12 +133,6 @@ Server.prototype.servePath = function (pathname, status, headers, req, res, fini
 
     pathname = this.resolve(pathname);
 
-    // Only allow GET and HEAD requests
-    if (req.method !== 'GET' && req.method !== 'HEAD' && req.method !== 'POST') {
-        finish(405, { 'Allow': 'GET, HEAD' });
-        return promise;
-    }
-
     // Make sure we're not trying to access a
     // file outside of the root.
     if (pathname.indexOf(that.root) === 0) {
diff --git a/test/integration/node-static-test.js b/test/integration/node-static-test.js
index c1e5d39..31ef8c5 100644
--- a/test/integration/node-static-test.js
+++ b/test/integration/node-static-test.js
@@ -173,7 +173,21 @@ suite.addBatch({
       assert.equal(response.statusCode, 200);
     }
   }
-}).addBatch({
+})
+.addBatch({
+  'requesting POST': {
+    topic : function(){
+      request.post(TEST_SERVER + '/index.html', this.callback);
+    },
+    'should respond with 200' : function(error, response, body){
+      assert.equal(response.statusCode, 200);
+    },
+    'should not be empty' : function(error, response, body){
+      assert.isNotEmpty(body);
+    }
+  }
+})
+.addBatch({
   'requesting HEAD': {
     topic : function(){
       request.head(TEST_SERVER + '/index.html', this.callback);
@@ -182,7 +196,7 @@ suite.addBatch({
       assert.equal(response.statusCode, 200);
     },
     'head must has no body' : function(error, response, body){
-      assert.isUndefined(body);
+      assert.isEmpty(body);
     }
   }
 })
@@ -247,3 +261,4 @@ suite.addBatch({
     }
   }
 }).export(module);
+

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-static.git



More information about the Pkg-javascript-commits mailing list