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

Do not check body for pyramid context to avoid loading all request #184

Open
inkhey opened this issue Jun 6, 2019 · 1 comment
Open

Comments

@inkhey
Copy link
Contributor

inkhey commented Jun 6, 2019

line 53 of ext/pyramid/context.py does :
if req.body and req.content_type in ("application/json", "application/json-rpc"): json_body = req.json_body # TODO : raise exception if not correct , return 400 if uncorrect instead ? else: json_body = {}

req.body come from pyramid request and is processed by webob.

Problem is, that, checking req.body mean loading data and potentially all request (if you send a 700m file, it will load them in memory).

Simple fix may be
if req.content_type in ("application/json", "application/json-rpc") and req.body :

we can also do no try to load body and do a try catch on "req.json_body"

We should later probably return exception in case of empty content but changing the behavior here, mean breaking code (it happened in tracim with case we received are application/json content type with fully empty body, not json parsable)

@DvdBgr
Copy link

DvdBgr commented Jun 13, 2019

As discussed with @inkhey last week, I found no case that would explain the check of the request body.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants