class Async::HTTP::Protocol::HTTP2::Response::Stream
def accept_push_promise_stream(promised_stream_id, headers)
def accept_push_promise_stream(promised_stream_id, headers) stream = @connection.accept_push_promise_stream(promised_stream_id, &Stream.method(:accept)) stream.response.build_request(headers) @response.promises.enqueue(stream.response) return stream end
def close(error)
def close(error) super @response.promises.enqueue nil @exception = error notify! end
def initialize(*)
def initialize(*) super @response = Response.new(self) @notification = Async::Notification.new @exception = nil end
def notify!
def notify! if @notification @notification.signal @notification = nil end end
def receive_initial_headers(headers, end_stream)
def receive_initial_headers(headers, end_stream) headers.each do |key, value| if key == STATUS @response.status = Integer(value) elsif key == PROTOCOL @response.protocol = value elsif key == CONTENT_LENGTH @length = Integer(value) else add_header(key, value) end end @response.headers = @headers unless @response.valid? send_reset_stream(::Protocol::HTTP2::Error::PROTOCOL_ERROR) else # We only construct the input/body if data is coming. unless end_stream @input = Body::Writable.new(@length) @response.body = @input end end self.notify! return headers end
def wait
def wait # If you call wait after the headers were already received, it should return immediately: @notification&.wait if @exception raise @exception end end