Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

switch to 400 response for malformed uri

  • Loading branch information...
commit 11e9782cadff37bd7ae0a510bde81de883193bb6 1 parent e4cb3ae
@guybedford guybedford authored
Showing with 10 additions and 8 deletions.
  1. +8 −6 lib/node-static.js
  2. +2 −2 test/integration/node-static-test.js
View
14 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);
View
4 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({
Please sign in to comment.
Something went wrong with that request. Please try again.