class Rack::Multipart::Parser::BoundedIO

def read(size, outbuf = nil)

def read(size, outbuf = nil)
  return if @cursor >= @content_length
  left = @content_length - @cursor
  str = if left < size
          @io.read left, outbuf
        else
          @io.read size, outbuf
        end
  if str
    @cursor += str.bytesize
  else
    # Raise an error for mismatching content-length and actual contents
    raise EOFError, "bad content body"
  end
  str
end