Class: Rack::Multipart::Parser::BoundedIO
Do not use. This class is for internal use only.
Relationships & Source Files | |
Inherits: | Object |
Defined in: | lib/rack/multipart/parser.rb |
Class Method Summary
- .new(io, content_length) ⇒ BoundedIO constructor
Instance Method Summary
Constructor Details
.new(io, content_length) ⇒ BoundedIO
# File 'lib/rack/multipart/parser.rb', line 49
def initialize(io, content_length) @io = io @content_length = content_length @cursor = 0 end
Instance Method Details
#read(size, outbuf = nil)
[ GitHub ]# File 'lib/rack/multipart/parser.rb', line 55
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