Class: Async::HTTP::Body::Hijack
- Defined in:
- lib/async/http/body/hijack.rb
Overview
A body which is designed for hijacked connections.
Class Method Summary collapse
Instance Method Summary collapse
- #call(stream) ⇒ Object
-
#empty? ⇒ Boolean
Has the producer called #finish and has the reader consumed the nil token?.
-
#initialize(input = nil, &block) ⇒ Hijack
constructor
A new instance of Hijack.
- #inspect ⇒ Object
-
#read ⇒ Object
Read the next available chunk.
Methods inherited from Readable
#close, #each, #finish, #join, #length
Constructor Details
#initialize(input = nil, &block) ⇒ Hijack
Returns a new instance of Hijack.
37 38 39 40 41 42 43 |
# File 'lib/async/http/body/hijack.rb', line 37 def initialize(input = nil, &block) @input = input @block = block @task = nil @stream = nil end |
Class Method Details
.response(request, status, headers, &block) ⇒ Object
29 30 31 |
# File 'lib/async/http/body/hijack.rb', line 29 def self.response(request, status, headers, &block) Async::HTTP::Response[status, headers, self.wrap(request, &block)] end |
.wrap(request, &block) ⇒ Object
33 34 35 |
# File 'lib/async/http/body/hijack.rb', line 33 def self.wrap(request, &block) self.new(request.body, &block) end |
Instance Method Details
#call(stream) ⇒ Object
45 46 47 |
# File 'lib/async/http/body/hijack.rb', line 45 def call(stream) return @block.call(stream) end |
#empty? ⇒ Boolean
Has the producer called #finish and has the reader consumed the nil token?
50 51 52 53 54 55 56 |
# File 'lib/async/http/body/hijack.rb', line 50 def empty? if @stream @stream.empty? else false end end |
#inspect ⇒ Object
71 72 73 |
# File 'lib/async/http/body/hijack.rb', line 71 def inspect "\#<#{self.class} #{@block.inspect}>" end |