class Rack::Multipart::Parser::Collector
Public Class Methods
new(tempfile)
click to toggle source
# File lib/rack/multipart/parser.rb, line 123 def initialize(tempfile) @tempfile = tempfile @mime_parts = [] @open_files = 0 end
Public Instance Methods
each() { |part| ... }
click to toggle source
# File lib/rack/multipart/parser.rb, line 129 def each @mime_parts.each { |part| yield part } end
on_mime_body(mime_index, content)
click to toggle source
# File lib/rack/multipart/parser.rb, line 149 def on_mime_body(mime_index, content) @mime_parts[mime_index].body << content end
on_mime_finish(mime_index)
click to toggle source
# File lib/rack/multipart/parser.rb, line 153 def on_mime_finish(mime_index) end
on_mime_head(mime_index, head, filename, content_type, name)
click to toggle source
# File lib/rack/multipart/parser.rb, line 133 def on_mime_head(mime_index, head, filename, content_type, name) if filename body = @tempfile.call(filename, content_type) body.binmode if body.respond_to?(:binmode) klass = TempfilePart @open_files += 1 else body = String.new klass = BufferPart end @mime_parts[mime_index] = klass.new(body, head, filename, content_type, name) check_part_limits end
Private Instance Methods
check_part_limits()
click to toggle source
# File lib/rack/multipart/parser.rb, line 158 def check_part_limits file_limit = Utils.multipart_file_limit part_limit = Utils.multipart_total_part_limit if file_limit && file_limit > 0 if @open_files >= file_limit @mime_parts.each(&:close) raise MultipartPartLimitError, 'Maximum file multiparts in content reached' end end if part_limit && part_limit > 0 if @mime_parts.size >= part_limit @mime_parts.each(&:close) raise MultipartTotalPartLimitError, 'Maximum total multiparts in content reached' end end end