Reverts the hard test for a 'PUT' request method (8d01dc0) and uses the Content-Type to determine whether to read into the request body. The Request#POST method parses the request body if (and only if) either of the following conditions are met: 1. The request's Content-Type is application/x-www-form-urlencoded or multipart/form-data. Note: the REQUEST_METHOD is ignored in this case. 2. The original REQUEST_METHOD is 'POST' and no Content-Type header was specified in the request. Note that we use the REQUEST_METHOD value before any modifications by the MethodOverride middleware. This is very similar to how this worked prior to 8d01dc0 but narrows the 'no Content-Type' special case to apply only to POST requests. A PUT request with no Content-Type header would trigger parsing before - with this change only POST requests with no Content-Type trigger parsing.
can change their behavior [#71 state:resolved]
…are both missing
…ng the uninitialized rack.request.form_hash Signed-off-by: Joshua Peek <firstname.lastname@example.org>
…ewindable, because rack.input is now required to be rewindable.
…rse_nested_query now chooses the last value instead of returning an array of all of them.
…o rewind the input stream.
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