Module: HTTPX::Plugins::H2C::ConnectionMethods

Defined in:
lib/httpx/plugins/h2c.rb

Instance Method Summary collapse

Instance Method Details

#build_parserObject



106
107
108
109
110
# File 'lib/httpx/plugins/h2c.rb', line 106

def build_parser(*)
  return super unless @origin.scheme == "http"

  super("http/1.1")
end

#coalescable?(connection) ⇒ Boolean

Returns:

  • (Boolean)


93
94
95
96
97
# File 'lib/httpx/plugins/h2c.rb', line 93

def coalescable?(connection)
  return super unless @options.fallback_protocol == "h2c" && @origin.scheme == "http"

  @origin == connection.origin && connection.options.fallback_protocol == "h2c"
end

#match?(uri, options) ⇒ Boolean

Returns:

  • (Boolean)


87
88
89
90
91
# File 'lib/httpx/plugins/h2c.rb', line 87

def match?(uri, options)
  return super unless uri.scheme == "http" && @options.fallback_protocol == "h2c"

  super && options.fallback_protocol == "h2c"
end

#upgrade(request, response) ⇒ Object



99
100
101
102
103
104
# File 'lib/httpx/plugins/h2c.rb', line 99

def upgrade(request, response)
  @parser.reset if @parser
  @parser = H2CParser.new(@write_buffer, @options)
  set_parser_callbacks(@parser)
  @parser.upgrade(request, response)
end