Class: Async::HTTP::Protocol::HTTP2::Output
- Inherits:
- 
      Object
      
        - Object
- Async::HTTP::Protocol::HTTP2::Output
 
- Defined in:
- lib/async/http/protocol/http2/output.rb
Instance Attribute Summary collapse
- 
  
    
      #trailers  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    Returns the value of attribute trailers. 
Instance Method Summary collapse
- 
  
    
      #close(error = nil)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    This method should only be called from within the context of the output task. 
- 
  
    
      #initialize(stream, body, trailers = nil)  ⇒ Output 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    A new instance of Output. 
- #start(parent: Task.current) ⇒ Object
- 
  
    
      #stop(error)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    This method should only be called from within the context of the HTTP/2 stream. 
- #window_updated(size) ⇒ Object
- #write(chunk) ⇒ Object
Constructor Details
#initialize(stream, body, trailers = nil) ⇒ Output
Returns a new instance of Output.
| 30 31 32 33 34 35 36 37 38 | # File 'lib/async/http/protocol/http2/output.rb', line 30 def initialize(stream, body, trailers = nil) @stream = stream @body = body @trailers = trailers @task = nil @window_updated = Async::Condition.new end | 
Instance Attribute Details
#trailers ⇒ Object (readonly)
Returns the value of attribute trailers.
| 40 41 42 | # File 'lib/async/http/protocol/http2/output.rb', line 40 def trailers @trailers end | 
Instance Method Details
#close(error = nil) ⇒ Object
This method should only be called from within the context of the output task.
| 71 72 73 74 75 76 | # File 'lib/async/http/protocol/http2/output.rb', line 71 def close(error = nil) if @stream @stream.finish_output(error) @stream = nil end end | 
#start(parent: Task.current) ⇒ Object
| 42 43 44 45 46 47 48 49 50 | # File 'lib/async/http/protocol/http2/output.rb', line 42 def start(parent: Task.current) raise "Task already started!" if @task if @body.respond_to?(:call) @task = parent.async(&self.method(:stream)) else @task = parent.async(&self.method(:passthrough)) end end | 
#stop(error) ⇒ Object
This method should only be called from within the context of the HTTP/2 stream.
| 79 80 81 82 | # File 'lib/async/http/protocol/http2/output.rb', line 79 def stop(error) @task&.stop @task = nil end | 
#window_updated(size) ⇒ Object
| 52 53 54 | # File 'lib/async/http/protocol/http2/output.rb', line 52 def window_updated(size) @window_updated.signal end | 
#write(chunk) ⇒ Object
| 56 57 58 59 60 61 62 63 64 65 66 67 68 | # File 'lib/async/http/protocol/http2/output.rb', line 56 def write(chunk) until chunk.empty? maximum_size = @stream.available_frame_size while maximum_size <= 0 @window_updated.wait maximum_size = @stream.available_frame_size end break unless chunk = send_data(chunk, maximum_size) end end |