diff options
author | 2017-02-15 10:37:53 -0500 | |
---|---|---|
committer | 2017-02-15 10:40:37 -0500 | |
commit | 324ee36fe31763e507b422ab0a88e4230045e205 (patch) | |
tree | d0b04520f6657601c918ce63fd27575977624187 /dgbuilder/dgeflows/node_modules/body-parser/lib/types/text.js | |
parent | f0c97e8db427481e28c0a16b789bc73801b35e47 (diff) |
Initial commit for OpenECOMP SDN-C OA&M
Change-Id: I7ab579fd0d206bf356f36d52dcdf4f71f1fa2680
Signed-off-by: Timoney, Daniel (dt5972) <dtimoney@att.com>
Former-commit-id: 2a9f0edd09581f907e62ec4689b5ac94dd5382ba
Diffstat (limited to 'dgbuilder/dgeflows/node_modules/body-parser/lib/types/text.js')
-rw-r--r-- | dgbuilder/dgeflows/node_modules/body-parser/lib/types/text.js | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/dgbuilder/dgeflows/node_modules/body-parser/lib/types/text.js b/dgbuilder/dgeflows/node_modules/body-parser/lib/types/text.js new file mode 100644 index 00000000..2330b5ba --- /dev/null +++ b/dgbuilder/dgeflows/node_modules/body-parser/lib/types/text.js @@ -0,0 +1,66 @@ +/*! + * body-parser + * Copyright(c) 2014 Douglas Christopher Wilson + * MIT Licensed + */ + +/** + * Module dependencies. + */ + +var bytes = require('bytes') +var read = require('../read') +var typeis = require('type-is') +var typer = require('media-typer') + +/** + * Module exports. + */ + +module.exports = text + +/** + * Create a middleware to parse text bodies. + * + * @param {object} [options] + * @return {function} + * @api public + */ + +function text(options) { + options = options || {}; + + var defaultCharset = options.defaultCharset || 'utf-8' + var inflate = options.inflate !== false + var limit = typeof options.limit !== 'number' + ? bytes(options.limit || '100kb') + : options.limit + var type = options.type || 'text/plain' + var verify = options.verify || false + + if (verify !== false && typeof verify !== 'function') { + throw new TypeError('option verify must be function') + } + + function parse(buf) { + return buf + } + + return function textParser(req, res, next) { + if (req._body) return next() + req.body = req.body || {} + + if (!typeis(req, type)) return next() + + // get charset + var charset = typer.parse(req).parameters.charset || defaultCharset + + // read + read(req, res, next, parse, { + encoding: charset, + inflate: inflate, + limit: limit, + verify: verify + }) + } +} |