Skip to content

Commit

Permalink
feat(plugins): do not include user-input in UnsupportedMediaTypeError…
Browse files Browse the repository at this point in the history
… message (VError fails), move it to info (#1733)
  • Loading branch information
hekike committed Jan 2, 2019
1 parent 71aac42 commit 06c220d
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions lib/plugins/bodyReader.js
Expand Up @@ -95,7 +95,7 @@ function bodyReader(options) {
var hash;
var md5;

var unsupportedCompression;
var unsupportedContentEncoding;

if ((md5 = req.headers['content-md5'])) {
hash = crypto.createHash('md5');
Expand All @@ -104,9 +104,17 @@ function bodyReader(options) {
function done() {
bodyWriter.end();

if (unsupportedCompression) {
var error = unsupportedCompression + ' not supported';
next(new UnsupportedMediaTypeError(error));
if (unsupportedContentEncoding) {
next(
new UnsupportedMediaTypeError(
{
info: {
contentEncoding: unsupportedContentEncoding
}
},
'content encoding not supported'
)
);
return;
}

Expand Down Expand Up @@ -149,7 +157,7 @@ function bodyReader(options) {
gz.once('end', done);
req.once('end', gz.end.bind(gz));
} else {
unsupportedCompression = req.headers['content-encoding'];
unsupportedContentEncoding = req.headers['content-encoding'];
res.setHeader('Accept-Encoding', 'gzip');
req.once('end', done);
}
Expand Down

0 comments on commit 06c220d

Please sign in to comment.