module HTTPX::Plugins::H2::ConnectionMethods

  1. lib/httpx/plugins/upgrade/h2.rb

Methods

Public Instance

  1. interests
  2. upgrade_to_h2

Public Instance methods

interests()
[show source]
   # File lib/httpx/plugins/upgrade/h2.rb
25 def interests
26   return super unless connecting? && @parser
27 
28   connect
29 
30   return @io.interests if connecting?
31 
32   super
33 end
upgrade_to_h2()
[show source]
   # File lib/httpx/plugins/upgrade/h2.rb
35 def upgrade_to_h2
36   prev_parser = @parser
37 
38   if prev_parser
39     prev_parser.reset
40     @inflight -= prev_parser.requests.size
41   end
42 
43   @parser = Connection::HTTP2.new(@write_buffer, @options)
44   set_parser_callbacks(@parser)
45   @upgrade_protocol = "h2"
46 
47   # what's happening here:
48   # a deviation from the state machine is done to perform the actions when a
49   # connection is closed, without transitioning, so the connection is kept in the pool.
50   # the state is reset to initial, so that the socket reconnect works out of the box,
51   # while the parser is already here.
52   purge_after_closed
53   transition(:idle)
54 
55   prev_parser.requests.each do |req|
56     req.transition(:idle)
57     send(req)
58   end
59 end