better handling of content-length variations

This commit is contained in:
Jonathan Lipps 2013-01-23 12:27:27 -08:00
Родитель caae26bacb
Коммит 2679d5f360
1 изменённых файлов: 9 добавлений и 3 удалений

Просмотреть файл

@ -19,12 +19,18 @@ var main = function(args, readyCb, doneCb) {
var bodyParser = express.bodyParser()
, parserWrap = function(req, res, next) {
// wd.js sends us http POSTs with empty body which will make bodyParser fail.
if (parseInt(req.get('content-length'), 10) <= 0) {
return next();
var cLen = req.get('content-length');
if (typeof cLen === "undefined" || parseInt(cLen, 10) <= 0) {
req.headers['content-length'] = 0;
next();
} else {
bodyParser(req, res, next);
}
bodyParser(req, res, next);
};
rest.use(function(req, res, next) {
next();
});
rest.use(express.favicon());
rest.use(express.static(path.join(__dirname, '/app/static')));
if (args.verbose) {