stream-utils / raw-body

Get and validate the raw body of a readable stream

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

automatically gunzip

jonathanong opened this issue · comments

need to check the limit on both the compressed body and the resulting uncompressed body.

expressjs/body-parser#20

What is the purpose of adding it to this module? I was just going to update inflation module and use inflation + raw-body within body-parser.

if there's a content-encoding and a content-length, you want to assert the content-length before decompressing. i guess you could do that in inflation as well. raw-body could just use inflation. primarily, i'd like to be able to just do rawBody(req, 'utf8', function (err, string) {}) and have rawBody check the headers automatically as in #21 (assuming no limit)

i guess you could do that in inflation as well

right, that's what i was originally thinking.

primarily, i'd like to be able to just do rawBody(req, 'utf8', function (err, string) {}) and have rawBody check the headers automatically as in #21 (assuming no limit)

that makes sense, especially if there is an option to opt-out of decompressing (and in that case, it would just error if content-encoding is not identity).