Class: Rackup::Stream
Relationships & Source Files | |
Namespace Children | |
Modules:
| |
Super Chains via Extension / Inclusion / Inheritance | |
Instance Chain:
self,
Reader
|
|
Inherits: | Object |
Defined in: | lib/rackup/stream.rb |
Overview
The input stream is an IO-like object which contains the raw HTTP POST data. When applicable, its external encoding must be “ASCII-8BIT” and it must be opened in binary mode, for Ruby 1.9 compatibility. The input stream must respond to gets, each, read and rewind.
Class Method Summary
Instance Attribute Summary
-
#closed? ⇒ Boolean
readonly
Whether the stream has been closed.
-
#empty? ⇒ Boolean
readonly
Whether there are any output chunks remaining?
- #input readonly
- #output readonly
Instance Method Summary
- #<<(buffer)
-
#close(error = nil)
Close the input and output bodies.
- #close_read
-
#close_write
close must never be called on the input stream.
- #flush
- #write(buffer)
- #write_nonblock(buffer)
- #read_next private
Reader
- Included
#each, #gets, | |
#read | read behaves like |
#read_nonblock, | |
#read_partial | Read at most |
Constructor Details
.new(input = nil, output = Buffered.new) ⇒ Stream
Instance Attribute Details
#closed? ⇒ Boolean
(readonly)
Whether the stream has been closed.
# File 'lib/rackup/stream.rb', line 179
def closed? @closed end
#empty? ⇒ Boolean
(readonly)
Whether there are any output chunks remaining?
# File 'lib/rackup/stream.rb', line 184
def empty? @output.empty? end
#input (readonly)
[ GitHub ]# File 'lib/rackup/stream.rb', line 20
attr :input
#output (readonly)
[ GitHub ]# File 'lib/rackup/stream.rb', line 21
attr :output
Instance Method Details
#<<(buffer)
[ GitHub ]# File 'lib/rackup/stream.rb', line 147
def <<(buffer) write(buffer) end
#close(error = nil)
Close the input and output bodies.
# File 'lib/rackup/stream.rb', line 169
def close(error = nil) self.close_read self.close_write return nil ensure @closed = true end
#close_read
[ GitHub ]# File 'lib/rackup/stream.rb', line 154
def close_read @input&.close @input = nil end
#close_write
close must never be called on the input stream. huh?
#flush
[ GitHub ]# File 'lib/rackup/stream.rb', line 151
def flush end
#read_next (private)
[ GitHub ]# File 'lib/rackup/stream.rb', line 190
def read_next if @input return @input.read else @input = nil raise IOError, "Stream is not readable, input has been closed!" end end
#write(buffer)
[ GitHub ]# File 'lib/rackup/stream.rb', line 134
def write(buffer) if @output @output.write(buffer) return buffer.bytesize else raise IOError, "Stream is not writable, output has been closed!" end end
#write_nonblock(buffer)
[ GitHub ]# File 'lib/rackup/stream.rb', line 143
def write_nonblock(buffer) write(buffer) end