class Async::HTTP::Protocol::HTTP2::Request
Typically used on the server side to represent an incoming request, and write the response.
Constants
- NO_RESPONSE
Attributes
stream[R]
Public Class Methods
new(stream)
click to toggle source
Calls superclass method
# File lib/async/http/protocol/http2/request.rb, line 104 def initialize(stream) super(nil, nil, nil, nil, VERSION, nil) @stream = stream end
Public Instance Methods
connection()
click to toggle source
# File lib/async/http/protocol/http2/request.rb, line 112 def connection @stream.connection end
hijack?()
click to toggle source
# File lib/async/http/protocol/http2/request.rb, line 120 def hijack? false end
send_response(response)
click to toggle source
# File lib/async/http/protocol/http2/request.rb, line 128 def send_response(response) if response.nil? return @stream.send_headers(nil, NO_RESPONSE, ::Protocol::HTTP2::END_STREAM) end protocol_headers = [ [STATUS, response.status], ] if protocol = response.protocol protocol_headers << [PROTOCOL, protocol] end if length = response.body&.length protocol_headers << [CONTENT_LENGTH, length] end headers = ::Protocol::HTTP::Headers::Merged.new(protocol_headers, response.headers) if body = response.body and !self.head? # This function informs the headers object that any subsequent headers are going to be trailer. Therefore, it must be called *before* sending the headers, to avoid any race conditions. trailer = response.headers.trailer! @stream.send_headers(nil, headers) @stream.send_body(body, trailer) else # Ensure the response body is closed if we are ending the stream: response.close @stream.send_headers(nil, headers, ::Protocol::HTTP2::END_STREAM) end end
valid?()
click to toggle source
# File lib/async/http/protocol/http2/request.rb, line 116 def valid? @scheme and @method and @path end