puma / puma

A Ruby/Rack web server built for parallelism
https://puma.io
BSD 3-Clause "New" or "Revised" License
7.7k stars 1.44k forks source link

Feature request: Handling large incoming requests before they are fully received. #81

Closed jammi closed 11 years ago

jammi commented 12 years ago

A common issue is dealing with huge uploads and other long-running requests, like demonstrated by slowloris DOS attacks. In some cases, the DOS attack could be someone posting /dev/urandom to a http server, slowly filling its memory. In the slowloris case, the attack is just a really slow client. IMO, there should be an api for dealing with these cases separately, so before the user's code is called, there should be some kind of an hook that a request has been initiated, but not not complete yet, maybe another to signal that the headers are received and additionally something to inspect the status of the request body transmission. Could be very useful for regular cases of large file uploads, receiving audio/video streams and such.

evanphx commented 11 years ago

Puma requires the client provide a valid Content-Length header in order to provide a body. In that case, there is no ability to stream an unknown number of bytes into puma. For very large files, there could be an option to limit the body size. Most people would do that via nginx and such.