You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In Rack::MethodOverride#method_override a Rack::Request instance is being created, which involves storing uploaded file in a temp file. This Rack::Request instance is only used to check for request_method input and then is abandoned, along with temp file.
Rails then creates its own Rack::Request instance (with a new temp file). So each uploaded file causes two identical temp files to appear.
Yeah, we've wanted to memoize Rack::Request objects for a while. This was removed some time ago because it was no implemented correctly. We can likely move to a model where Rack::Request memoizes into self.class.name, but we'd have to be sure we're not breaking existing frameworks. I will defer until 2.0 unless someone sends through a working patch tested against common frameworks.
In Rack::MethodOverride#method_override a Rack::Request instance is being created, which involves storing uploaded file in a temp file. This Rack::Request instance is only used to check for request_method input and then is abandoned, along with temp file.
I don't know what was in 2014, but now the parsed multipart body is cached in the env hash (in rack.request.form_hash), so the multipart parsing happens only once even if you instantiate multiple Rack::Request objects. The following script proves it:
Only upon next Garbage Collection Rack::Request instances are swept and temp files deleted
This isn't the behaviour anymore since the addition of the Rack::TempfileReaper middleware, which deletes tempfiles created during multipart parsing at the end of the request.
Since Rack doesn't have the problems mentioned in this issue anymore, I think this issue can be closed.
https://github.com/rack/rack/blob/master/lib/rack/methodoverride.rb#L25
In
Rack::MethodOverride#method_override
a Rack::Request instance is being created, which involves storing uploaded file in a temp file. This Rack::Request instance is only used to check forrequest_method
input and then is abandoned, along with temp file.Rails then creates its own Rack::Request instance (with a new temp file). So each uploaded file causes two identical temp files to appear.
Only upon next Garbage Collection Rack::Request instances are swept and temp files deleted (https://groups.google.com/d/topic/rack-devel/brK8eh-MByw/discussion).
The text was updated successfully, but these errors were encountered: