summary refs log tree commit
path: root/lib/rack/multipart/parser.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/rack/multipart/parser.rb')
-rw-r--r--lib/rack/multipart/parser.rb11
1 files changed, 8 insertions, 3 deletions
diff --git a/lib/rack/multipart/parser.rb b/lib/rack/multipart/parser.rb
index fa47fd16..22f9734b 100644
--- a/lib/rack/multipart/parser.rb
+++ b/lib/rack/multipart/parser.rb
@@ -16,10 +16,10 @@ module Rack
         content_length = env['CONTENT_LENGTH']
         content_length = content_length.to_i if content_length
 
-        new($1, io, content_length)
+        new($1, io, content_length, env)
       end
 
-      def initialize(boundary, io, content_length)
+      def initialize(boundary, io, content_length, env)
         @buf            = ""
 
         if @buf.respond_to? :force_encoding
@@ -31,6 +31,7 @@ module Rack
         @io             = io
         @content_length = content_length
         @boundary_size  = Utils.bytesize(@boundary) + EOL.size
+        @env = env
 
         if @content_length
           @content_length -= @boundary_size
@@ -111,8 +112,12 @@ module Rack
 
             filename = get_filename(head)
 
+            if name.nil? || name.empty? && filename
+              name = filename
+            end
+
             if filename
-              body = Tempfile.new("RackMultipart")
+              (@env['rack.tempfiles'] ||= []) << body = Tempfile.new("RackMultipart")
               body.binmode  if body.respond_to?(:binmode)
             end