diff --git a/lib/rack/multipart/parser.rb b/lib/rack/multipart/parser.rb index a19d6ea32..94f0fae39 100644 --- a/lib/rack/multipart/parser.rb +++ b/lib/rack/multipart/parser.rb @@ -39,8 +39,6 @@ def read(size) str end - def eof?; @content_length == @cursor; end - def rewind @io.rewind end @@ -65,11 +63,11 @@ def self.parse(io, content_length, content_type, tmpfile, bufsize, qp) io = BoundedIO.new(io, content_length) if content_length parser = new(boundary, tmpfile, bufsize, qp) - parser.on_read io.read(bufsize), io.eof? + parser.on_read io.read(bufsize) loop do break if parser.state == :DONE - parser.on_read io.read(bufsize), io.eof? + parser.on_read io.read(bufsize) end io.rewind @@ -181,8 +179,8 @@ def initialize(boundary, tempfile, bufsize, query_parser) @collector = Collector.new tempfile end - def on_read content, eof - handle_empty_content!(content, eof) + def on_read content + handle_empty_content!(content) @buf << content run_parser end @@ -358,10 +356,9 @@ def tag_multipart_encoding(filename, content_type, name, body) end - def handle_empty_content!(content, eof) + def handle_empty_content!(content) if content.nil? || content.empty? - raise EOFError if eof - return true + raise EOFError end end end