Skip to content
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

node12: add limit environment variable for raw (application/octet-stream) #245

Closed
fundef1 opened this issue Jan 29, 2021 · 1 comment · Fixed by #247
Closed

node12: add limit environment variable for raw (application/octet-stream) #245

fundef1 opened this issue Jan 29, 2021 · 1 comment · Fixed by #247

Comments

@fundef1
Copy link

fundef1 commented Jan 29, 2021

I can't seem to set the limit for bodyParser.raw - i.e. when using a Content-Type: application/octet-stream

Expected Behaviour

i was expecting an equivalent to the MAX_JSON_SIZE environment variable.
I'm not a (js) programmer, but I couldn't find a clean way to set the limit for the raw parser.

Current Behaviour

bodyParser.raw defaults to 100kb

Possible Solution

I hacked the node12 template locally and simply added a MAX_RAW_SIZE, but there's probably a cleaner way.

    var jsonLimit = process.env.MAX_JSON_SIZE || '100kb' //body-parser default
    var rawLimit = process.env.MAX_RAW_SIZE || '100kb' //body-parser default
    app.use(bodyParser.json({ limit: jsonLimit}));
    app.use(bodyParser.raw({ limit: rawLimit})); // "Content-Type: application/octet-stream"
    app.use(bodyParser.text({ type : "text/*" }));

a generic MAX_SIZE might be cleaner though.

@alexellis
Copy link
Member

alexellis commented Jan 29, 2021

So, like this, but for MAX_RAW_SIZE?

Fine with that.

fundef1 added a commit to fundef1/templates that referenced this issue Jan 30, 2021
cfr. openfaas#245

moved rawLimit out of if clause , so it can be applied to RAW_BODY as well. Is more consistent this way.
alexellis added a commit that referenced this issue Feb 10, 2021
Fixes: #245
Closes: #246

Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alexellis2@gmail.com>
alexellis added a commit that referenced this issue Feb 10, 2021
Fixes: #245
Closes: #246

Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alexellis2@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants