Skip to content

refactor: move req.body = undefined to just before read attempt #602

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions lib/types/json.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down Expand Up @@ -121,6 +117,10 @@ function json (options) {
return
}

if (!('body' in req)) {
req.body = undefined
}

// read
read(req, res, next, parse, debug, {
encoding: charset,
Expand Down
8 changes: 4 additions & 4 deletions lib/types/raw.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -64,6 +60,10 @@ function raw (options) {
return
}

if (!('body' in req)) {
req.body = undefined
}

// read
read(req, res, next, parse, debug, {
encoding: null,
Expand Down
8 changes: 4 additions & 4 deletions lib/types/text.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -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,
Expand Down
8 changes: 4 additions & 4 deletions lib/types/urlencoded.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down Expand Up @@ -89,6 +85,10 @@ function urlencoded (options) {
return
}

if (!('body' in req)) {
req.body = undefined
}

// read
read(req, res, next, parse, debug, {
encoding: charset,
Expand Down
Loading