module Async::HTTP::Protocol::HTTP2::Connection
def connected?
def connected? @stream.connected? end
def http1?
def http1? false end
def http2?
def http2? true end
def initialize(*)
def initialize(*) super @count = 0 @reader = nil # Writing multiple frames at the same time can cause odd problems if frames are only partially written. So we use a semaphore to ensure frames are written in their entirety. @write_frame_guard = Async::Semaphore.new(1) end
def multiplex
def multiplex @remote_settings.maximum_concurrent_streams end
def peer
def peer @stream.io end
def read_in_background(task: Task.current)
def read_in_background(task: Task.current) task.async do |nested_task| nested_task.annotate("#{version} reading data for #{self.class}") begin while !self.closed? self.read_frame end rescue EOFError, Async::Wrapper::Cancelled # Stream closed. ensure stop_connection($!) end end end
def reusable?
def reusable? !(self.closed? || @stream.closed?) end
def start_connection
def start_connection @reader ||= read_in_background end
def stop_connection(error)
def stop_connection(error) @reader = nil end
def version
def version VERSION end
def write_frame(frame)
def write_frame(frame) # We don't want to write multiple frames at the same time. @write_frame_guard.acquire do super end end