class Andpush::Http2RequestHandler
Constants
- BY_HEADER_LINE
- EMPTY_HEADERS
- HEADER_VALUE
- Response
Attributes
multi[R]
Public Class Methods
new(max_connects: 100)
click to toggle source
# File lib/andpush.rb, line 68 def initialize(max_connects: 100) @multi = Curl::Multi.new @multi.pipeline = Curl::CURLPIPE_MULTIPLEX if defined?(Curl::CURLPIPE_MULTIPLEX) @multi.max_connects = max_connects end
Public Instance Methods
call(request_class, uri, headers, body, *_)
click to toggle source
# File lib/andpush.rb, line 75 def call(request_class, uri, headers, body, *_) easy = Curl::Easy.new(uri.to_s) easy.multi = @multi easy.headers = headers || EMPTY_HEADERS easy.post_body = body if request_class::REQUEST_HAS_BODY if defined?(Curl::CURLPIPE_MULTIPLEX) # This ensures libcurl waits for the connection to reveal if it is # possible to pipeline/multiplex on before it continues. easy.setopt(Curl::CURLOPT_PIPEWAIT, 1) easy.version = Curl::HTTP_2_0 end easy.public_send(:"http_#{request_class::METHOD.downcase}") Response.new( Hash[easy.header_str.split(BY_HEADER_LINE).flat_map {|s| s.scan(HEADER_VALUE) }], easy.body, easy.response_code.to_s, # to_s for compatibility with Net::HTTP easy, ).freeze end