diff --git a/lib/types/json.js b/lib/types/json.js index 078ce710..75948ccc 100644 --- a/lib/types/json.js +++ b/lib/types/json.js @@ -90,10 +90,6 @@ function json (options) { return } - if (!('body' in req)) { - req.body = undefined - } - // skip requests without bodies if (!typeis.hasBody(req)) { debug('skip empty body') @@ -121,6 +117,10 @@ function json (options) { return } + if (!('body' in req)) { + req.body = undefined + } + // read read(req, res, next, parse, debug, { encoding: charset, diff --git a/lib/types/raw.js b/lib/types/raw.js index 3788ff27..f96814e1 100644 --- a/lib/types/raw.js +++ b/lib/types/raw.js @@ -44,10 +44,6 @@ function raw (options) { return } - if (!('body' in req)) { - req.body = undefined - } - // skip requests without bodies if (!typeis.hasBody(req)) { debug('skip empty body') @@ -64,6 +60,10 @@ function raw (options) { return } + if (!('body' in req)) { + req.body = undefined + } + // read read(req, res, next, parse, debug, { encoding: null, diff --git a/lib/types/text.js b/lib/types/text.js index 3e0ab1bb..2920a86c 100644 --- a/lib/types/text.js +++ b/lib/types/text.js @@ -46,10 +46,6 @@ function text (options) { return } - if (!('body' in req)) { - req.body = undefined - } - // skip requests without bodies if (!typeis.hasBody(req)) { debug('skip empty body') @@ -69,6 +65,10 @@ function text (options) { // get charset var charset = getCharset(req) || defaultCharset + if (!('body' in req)) { + req.body = undefined + } + // read read(req, res, next, parse, debug, { encoding: charset, diff --git a/lib/types/urlencoded.js b/lib/types/urlencoded.js index f993425e..2768b2de 100644 --- a/lib/types/urlencoded.js +++ b/lib/types/urlencoded.js @@ -58,10 +58,6 @@ function urlencoded (options) { return } - if (!('body' in req)) { - req.body = undefined - } - // skip requests without bodies if (!typeis.hasBody(req)) { debug('skip empty body') @@ -89,6 +85,10 @@ function urlencoded (options) { return } + if (!('body' in req)) { + req.body = undefined + } + // read read(req, res, next, parse, debug, { encoding: charset,