class Rack::Files::BaseIterator

def bytesize

def bytesize
  size = ranges.inject(0) do |sum, range|
    sum += multipart_heading(range).bytesize if multipart?
    sum += range.size
  end
  size += "\r\n--#{MULTIPART_BOUNDARY}--\r\n".bytesize if multipart?
  size
end

def close; end

def close; end

def each

def each
  ::File.open(path, "rb") do |file|
    ranges.each do |range|
      yield multipart_heading(range) if multipart?
      each_range_part(file, range) do |part|
        yield part
      end
    end
    yield "\r\n--#{MULTIPART_BOUNDARY}--\r\n" if multipart?
  end
end

def each_range_part(file, range)

def each_range_part(file, range)
  file.seek(range.begin)
  remaining_len = range.end - range.begin + 1
  while remaining_len > 0
    part = file.read([8192, remaining_len].min)
    break unless part
    remaining_len -= part.length
    yield part
  end
end

def initialize(path, ranges, options)

def initialize(path, ranges, options)
  @path = path
  @ranges = ranges
  @options = options
end

def multipart?

def multipart?
  ranges.size > 1
end

def multipart_heading(range)

def multipart_heading(range)

LTIPART_BOUNDARY}\r
t-type: #{options[:mime_type]}\r
t-range: bytes #{range.begin}-#{range.end}/#{options[:size]}\r
end