[Pkg-javascript-commits] [node-static] 103/151: switch to 400 response for malformed uri
Tonnerre Lombard
tonnerre-guest at moszumanska.debian.org
Tue Jan 7 23:18:01 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 11e9782cadff37bd7ae0a510bde81de883193bb6
Author: guybedford <guybedford at gmail.com>
Date: Mon Feb 4 16:24:17 2013 +0200
switch to 400 response for malformed uri
---
lib/node-static.js | 14 ++++++++------
test/integration/node-static-test.js | 4 ++--
2 files changed, 10 insertions(+), 8 deletions(-)
diff --git a/lib/node-static.js b/lib/node-static.js
index 7ed7811..fde1f0e 100644
--- a/lib/node-static.js
+++ b/lib/node-static.js
@@ -171,18 +171,20 @@ exports.Server.prototype.serve = function (req, res, callback) {
var that = this,
promise = new(events.EventEmitter);
+ var finish = function (status, headers) {
+ that.finish(status, headers, req, res, promise, callback);
+ };
+
var pathname;
try {
- pathname = decodeURI(url.parse(req.url).pathname);
+ pathname = decodeURI(url.parse(req.url).pathname);
}
catch(e) {
- pathname = url.parse(req.url).pathname;
+ return process.nextTick(function() {
+ return finish(400, {});
+ });
}
- var finish = function (status, headers) {
- that.finish(status, headers, req, res, promise, callback);
- };
-
process.nextTick(function () {
that.servePath(pathname, 200, {}, req, res, finish).on('success', function (result) {
promise.emit('success', result);
diff --git a/test/integration/node-static-test.js b/test/integration/node-static-test.js
index df945c8..7559a68 100644
--- a/test/integration/node-static-test.js
+++ b/test/integration/node-static-test.js
@@ -83,8 +83,8 @@ suite.addBatch({
topic: function(){
request.get(TEST_SERVER + '/a%AFc', this.callback);
},
- 'should respond with 404': function(error, response, body){
- assert.equal(response.statusCode, 404);
+ 'should respond with 400': function(error, response, body){
+ assert.equal(response.statusCode, 400);
}
}
}).addBatch({
--
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