Public Class methods
new(*)
[show source]
# File lib/httpx/plugins/h2c.rb 48 def initialize(*) 49 super 50 @h2c_handshake = false 51 end
Public Instance methods
send(request)
[show source]
# File lib/httpx/plugins/h2c.rb 53 def send(request) 54 return super if @h2c_handshake 55 56 return super unless VALID_H2C_VERBS.include?(request.verb) && request.scheme == "http" 57 58 return super if @upgrade_protocol == "h2c" 59 60 @h2c_handshake = true 61 62 # build upgrade request 63 request.headers.add("connection", "upgrade") 64 request.headers.add("connection", "http2-settings") 65 request.headers["upgrade"] = "h2c" 66 request.headers["http2-settings"] = ::HTTP2::Client.settings_header(request.options.http2_settings) 67 68 super 69 end
upgrade_to_h2c(request, response)
[show source]
# File lib/httpx/plugins/h2c.rb 71 def upgrade_to_h2c(request, response) 72 prev_parser = @parser 73 74 if prev_parser 75 prev_parser.reset 76 @inflight -= prev_parser.requests.size 77 end 78 79 @parser = H2CParser.new(@write_buffer, @options) 80 set_parser_callbacks(@parser) 81 @inflight += 1 82 @parser.upgrade(request, response) 83 @upgrade_protocol = "h2c" 84 85 prev_parser.requests.each do |req| 86 req.transition(:idle) 87 send(req) 88 end 89 end