1 |
|
2 |
|
3 |
|
4 |
|
5 | var raw = require('raw-body');
|
6 | var inflate = require('inflation');
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 | module.exports = function(req, opts){
|
21 | req = req.req || req;
|
22 | opts = opts || {};
|
23 |
|
24 |
|
25 | var len = req.headers['content-length'];
|
26 | var encoding = req.headers['content-encoding'] || 'identity';
|
27 | if (len && encoding === 'identity') opts.length = ~~len;
|
28 | opts.encoding = opts.encoding || 'utf8';
|
29 | opts.limit = opts.limit || '1mb';
|
30 |
|
31 |
|
32 | return Promise.resolve()
|
33 | .then(function() {
|
34 | return raw(inflate(req), opts);
|
35 | });
|
36 | };
|