Module: HTTPX::Plugins::H2C::ConnectionMethods
- Defined in:
- lib/httpx/plugins/h2c.rb
Instance Method Summary collapse
Instance Method Details
#initialize ⇒ Object
54 55 56 57 |
# File 'lib/httpx/plugins/h2c.rb', line 54 def initialize(*) super @h2c_handshake = false end |
#send(request) ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/httpx/plugins/h2c.rb', line 59 def send(request) return super if @h2c_handshake return super unless request.valid_h2c_verb? && request.scheme == "http" return super if @upgrade_protocol == "h2c" @h2c_handshake = true # build upgrade request request.headers.add("connection", "upgrade") request.headers.add("connection", "http2-settings") request.headers["upgrade"] = "h2c" request.headers["http2-settings"] = ::HTTP2::Client.settings_header(request..http2_settings) super end |
#upgrade_to_h2c(request, response) ⇒ Object
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/httpx/plugins/h2c.rb', line 77 def upgrade_to_h2c(request, response) prev_parser = @parser if prev_parser prev_parser.reset @inflight -= prev_parser.requests.size end @parser = H2CParser.new(@write_buffer, @options) set_parser_callbacks(@parser) @inflight += 1 @parser.upgrade(request, response) @upgrade_protocol = "h2c" prev_parser.requests.each do |req| req.transition(:idle) send(req) end end |