Skip to content

Commit

Permalink
perf: skip buffer decoding on overage chunk
Browse files Browse the repository at this point in the history
closes #54
  • Loading branch information
kevinburke authored and dougwilson committed Sep 8, 2017
1 parent b545644 commit afcb732
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
1 change: 1 addition & 0 deletions HISTORY.md
Expand Up @@ -4,6 +4,7 @@ unreleased
* deps: bytes@3.0.0
* deps: http-errors@1.6.2
- deps: depd@1.1.1
* perf: skip buffer decoding on overage chunk

2.3.0 / 2017-08-04
==================
Expand Down
10 changes: 4 additions & 6 deletions index.js
Expand Up @@ -242,18 +242,16 @@ function readStream (stream, encoding, length, limit, callback) {

received += chunk.length

if (decoder) {
buffer += decoder.write(chunk)
} else {
buffer.push(chunk)
}

if (limit !== null && received > limit) {
done(createError(413, 'request entity too large', {
limit: limit,
received: received,
type: 'entity.too.large'
}))
} else if (decoder) {
buffer += decoder.write(chunk)
} else {
buffer.push(chunk)
}
}

Expand Down

0 comments on commit afcb732

Please sign in to comment.