Class: Protocol::Rack::Body::InputWrapper
- Inherits:
-
HTTP::Body::Readable
- Object
- HTTP::Body::Readable
- Protocol::Rack::Body::InputWrapper
- Defined in:
- lib/protocol/rack/body/input_wrapper.rb
Overview
Used for wrapping a generic ‘rack.input` object into a readable body.
Constant Summary collapse
- BLOCK_SIZE =
1024*4
Instance Method Summary collapse
- #close(error = nil) ⇒ Object
-
#initialize(io, block_size: BLOCK_SIZE) ⇒ InputWrapper
constructor
A new instance of InputWrapper.
-
#read ⇒ Object
def join @io.read.tap do |buffer| buffer.force_encoding(Encoding::BINARY) end end.
Constructor Details
#initialize(io, block_size: BLOCK_SIZE) ⇒ InputWrapper
Returns a new instance of InputWrapper.
16 17 18 19 20 21 |
# File 'lib/protocol/rack/body/input_wrapper.rb', line 16 def initialize(io, block_size: BLOCK_SIZE) @io = io @block_size = block_size super() end |
Instance Method Details
#close(error = nil) ⇒ Object
23 24 25 26 27 28 |
# File 'lib/protocol/rack/body/input_wrapper.rb', line 23 def close(error = nil) if @io @io.close @io = nil end end |
#read ⇒ Object
def join @io.read.tap do |buffer| buffer.force_encoding(Encoding::BINARY) end end
36 37 38 |
# File 'lib/protocol/rack/body/input_wrapper.rb', line 36 def read @io&.read(@block_size) end |