diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2015-08-28 17:16:31 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2015-08-28 17:16:55 -0700 |
commit | 3f6aee5544582abff3911e61dbe3c01506c63fbd (patch) | |
tree | 628a61f8d662feb93088b870df322e66e3fd5bd2 | |
parent | ae169837db4e8639c5dbecd4e586d18355c73527 (diff) | |
download | rack-3f6aee5544582abff3911e61dbe3c01506c63fbd.tar.gz |
remove IO from the mime parser's instance
-rw-r--r-- | lib/rack/multipart/parser.rb | 32 |
1 files changed, 10 insertions, 22 deletions
diff --git a/lib/rack/multipart/parser.rb b/lib/rack/multipart/parser.rb index 72b11dce..5a645169 100644 --- a/lib/rack/multipart/parser.rb +++ b/lib/rack/multipart/parser.rb @@ -64,8 +64,15 @@ module Rack io = BoundedIO.new(io, content_length) if content_length - parser = new(boundary, io, tmpfile, bufsize, qp) - parser.parse + parser = new(boundary, tmpfile, bufsize, qp) + parser.on_read io.read(bufsize), io.eof? + + loop do + break if parser.state == :DONE + parser.on_read io.read(bufsize), io.eof? + end + + io.rewind parser.result end @@ -159,13 +166,12 @@ module Rack attr_reader :state - def initialize(boundary, io, tempfile, bufsize, query_parser) + def initialize(boundary, tempfile, bufsize, query_parser) @buf = "".force_encoding(Encoding::ASCII_8BIT) @query_parser = query_parser @params = query_parser.make_params @boundary = "--#{boundary}" - @io = io @boundary_size = @boundary.bytesize + EOL.size @bufsize = bufsize @@ -180,21 +186,9 @@ module Rack def on_read content, eof handle_empty_content!(content, eof) @buf << content - run_parser end - def parse - on_read @io.read(@bufsize), @io.eof? - loop do - break if @state == :DONE - - on_read @io.read(@bufsize), @io.eof? - end - - @io.rewind - end - def result @collector.each do |part| part.get_data do |data| @@ -295,12 +289,6 @@ module Rack end end - def fast_forward_to_first_boundary - end - - def get_current_head_and_filename_and_content_type_and_name_and_body - end - def get_filename(head) filename = nil case head |