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

Prevent the full loading of content of HTTP POST requests into the RAM #253

Closed
hozblok opened this issue Mar 18, 2019 · 2 comments
Closed

Comments

@hozblok
Copy link

hozblok commented Mar 18, 2019

Please, can anyone say how to avoid the following behavior?

For example, we send a large HTTP POST request with multipart/form-data (~2 Gb) using channels, daphne, AsgiHandler and AsgiRequest. (let's say we chose the wrong file to upload).

settings.py contains DATA_UPLOAD_MAX_MEMORY_SIZE = 1024 * 1024 * 25 and FILE_UPLOAD_MAX_MEMORY_SIZE = 1024 * 1024 * 5 settings.

Here in AsgiRequest we raise RequestDataTooBig exception.

So the response is HttpResponse("413 Payload too large", status=413) (here). Ok.

But before all this: here we load two gigabytes of unwanted data into RAM... ?

Perhaps is there a way to check the content-length in the __init__ method of AsgiHandler? How to prevent uploads to RAM correctly?

@JohnDoee
Copy link
Contributor

I think this would be a dupe of #126.

Check out uvicorn, I'm pretty sure it'll handle large requests a lot better.

@carltongibson
Copy link
Member

Yep. This is a duplicate. It'll come but not available yet.

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

3 participants