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.
The Tempfile class in Ruby 1.8 doesn't implement the == method correctly. This causes Rack::Requests to re-parse the input (when the input is a Tempfile) each time the POST method is called, this in turn raises an EOFError because the input has already been read. One example of when this happens is when handling large POST requests (e.g. file uploads) under Mongrel. This issue only effects Ruby 1.8 (tested against 1.8.6). Ruby 1.9 does not suffer from this issue (presumably due to changes in the Delegate implementation.) darcs-hash:20080327110953-ea3b8-44b6f22da80c9dae70dcd61adc43111547371daf.gz
Fixes cases where accessing Request#params causes the body to be read and processed as form-data improperly. For example, consider the following request: PUT /foo/bar?baz=bizzle HTTP/1.1 Content-Type: text/plain This is not form-data. When Rack::Request gets ahold of the corresponding environment, and the application attempts to access the "baz" query string param, the body is read and interpreted as form-data. If the body is an IOish object, this causes the offset to be forwarded to the end of file. The patch prevents the Request#POST method from going into the body unless the media type is application/x-www-form-urlencoded, multipart/form-data, or not specified. While here, added a few unrelated helper methods to Request that I've found particularly useful in Rack apps: #content_length, #head?, and #content_charset. Tests and doc included for all changes. darcs-hash:20080315135144-8bfab-f12391851f188ab1467b7e3d825f1e196058210d.gz