Skip to content
Browse files

Avoid slurping or parsing request body on PUT requests

Uploading a large file via the HTTP PUT method causes
`@env["rack.input"].read' to be called inside the POST method.  This
means the entire file is slurped into memory and was needlessly causing
my Sinatra process to eat up 300M+ for some uploads I've been doing.
  • Loading branch information...
1 parent d032445 commit 8d01dc0421622f80fddfec52be66c49f8362162f Eric Wong committed with chneukirchen
Showing with 1 addition and 1 deletion.
  1. +1 −1 lib/rack/request.rb
View
2 lib/rack/request.rb
@@ -122,7 +122,7 @@ def POST
# The union of GET and POST data.
def params
- self.GET.update(self.POST)
+ self.put? ? self.GET : self.GET.update(self.POST)
rescue EOFError => e
self.GET
end

0 comments on commit 8d01dc0

Please sign in to comment.
Something went wrong with that request. Please try again.