class Async::HTTP::Protocol::HTTP2::Request
Typically used on the server side to represent an incoming request, and write the response.
def hijack?
def hijack? false end
def initialize(stream)
def initialize(stream) super(nil, nil, nil, nil, VERSION, nil) @stream = stream end
def push(path, headers = nil, scheme = @scheme, authority = @authority)
-
(Stream)
- the promised stream, on which to send data.
def push(path, headers = nil, scheme = @scheme, authority = @authority) raise ArgumentError, "Missing scheme!" unless scheme raise ArgumentError, "Missing authority!" unless authority push_headers = [ [SCHEME, scheme], [METHOD, ::Protocol::HTTP::Methods::GET], [PATH, path], [AUTHORITY, authority] ] if headers push_headers = Headers::Merged.new( push_headers, headers ) end @stream.send_push_promise(push_headers) end
def push?
def push? @stream.connection.enable_push? end
def send_response(response)
def send_response(response) if response.nil? @stream.send_headers(nil, NO_RESPONSE, ::Protocol::HTTP2::END_STREAM) elsif response.body? pseudo_headers = [ [STATUS, response.status], ] if protocol = response.protocol pseudo_headers << [PROTOCOL, protocol] end if length = response.body.length pseudo_headers << [CONTENT_LENGTH, length] end headers = ::Protocol::HTTP::Headers::Merged.new( pseudo_headers, response.headers ) @stream.send_headers(nil, headers) @stream.send_body(response.body) else headers = ::Protocol::HTTP::Headers::Merged.new([ [STATUS, response.status], ], response.headers) @stream.send_headers(nil, headers, ::Protocol::HTTP2::END_STREAM) end end
def valid?
def valid? @scheme and @method and @path end