4 * Copyright(c) 2010 Sencha Inc.
5 * Copyright(c) 2011 TJ Holowaychuk
10 * Module dependencies.
13 var utils = require('../utils')
14 , _limit = require('./limit')
21 function noop(req, res, next) {
28 * Parse x-ww-form-urlencoded request bodies,
29 * providing the parsed object as `req.body`.
33 * - `limit` byte limit disabled by default
35 * @param {Object} options
40 exports = module.exports = function(options){
41 options = options || {};
43 var limit = options.limit
44 ? _limit(options.limit)
47 return function urlencoded(req, res, next) {
48 if (req._body) return next();
49 req.body = req.body || {};
52 if ('application/x-www-form-urlencoded' != utils.mime(req)) return next();
58 limit(req, res, function(err){
59 if (err) return next(err);
61 req.setEncoding('utf8');
62 req.on('data', function(chunk){ buf += chunk });
63 req.on('end', function(){
66 ? qs.parse(buf, options)