module HTTPX::Plugins::H2C::InstanceMethods

  1. lib/httpx/plugins/h2c.rb

Methods

Public Instance

  1. request

Public Instance methods

request (*args, **options)
[show source]
   # File lib/httpx/plugins/h2c.rb
17 def request(*args, **options)
18   h2c_options = options.merge(fallback_protocol: "h2c")
19 
20   requests = build_requests(*args, h2c_options)
21 
22   upgrade_request = requests.first
23   return super unless valid_h2c_upgrade_request?(upgrade_request)
24 
25   upgrade_request.headers.add("connection", "upgrade")
26   upgrade_request.headers.add("connection", "http2-settings")
27   upgrade_request.headers["upgrade"] = "h2c"
28   upgrade_request.headers["http2-settings"] = HTTP2::Client.settings_header(upgrade_request.options.http2_settings)
29   wrap { send_requests(*upgrade_request, h2c_options).first }
30 
31   responses = send_requests(*requests, h2c_options)
32 
33   return responses.first if responses.size == 1
34 
35   responses
36 end