Module: HTTPX::Plugins::H2::ConnectionMethods

Defined in:
lib/httpx/plugins/upgrade/h2.rb

Instance Method Summary collapse

Instance Method Details

#interestsObject



25
26
27
28
29
30
31
32
33
# File 'lib/httpx/plugins/upgrade/h2.rb', line 25

def interests
  return super unless connecting? && @parser

  connect

  return @io.interests if connecting?

  super
end

#upgrade_to_h2Object



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/httpx/plugins/upgrade/h2.rb', line 35

def upgrade_to_h2
  enqueue_pending_requests_from_parser(@parser)

  @parser = @options.http2_class.new(@write_buffer, @options)
  set_parser_callbacks(@parser)
  @upgrade_protocol = "h2"

  # what's happening here:
  # a deviation from the state machine is done to perform the actions when a
  # connection is closed, without transitioning, so the connection is kept in the pool.
  # the state is reset to initial, so that the socket reconnect works out of the box,
  # while the parser is already here.
  purge_after_closed
  transition(:idle)
end