class HTTPX::Connection::HTTP2

  1. lib/httpx/connection/http2.rb
Superclass: Object

Methods

Public Class

  1. new

Public Instance

  1. <<
  2. close
  3. consume
  4. empty?
  5. handle_error
  6. pending
  7. reenqueue!
  8. send
  9. streams

Included modules

  1. Callbacks
  2. Loggable

Constants

Error = Class.new(Error) do def initialize(id, code) super("stream #{id} closed with error: #{code}") end end  

Attributes

pending [R]
streams [R]

Public Class methods

new (buffer, options)
[show source]
   # File lib/httpx/connection/http2.rb
35 def initialize(buffer, options)
36   @options = Options.new(options)
37   @max_concurrent_requests = @options.max_concurrent_requests
38   @pending = []
39   @streams = {}
40   @drains  = {}
41   @buffer = buffer
42   @handshake_completed = false
43   init_connection
44 end

Public Instance methods

<< (data)
[show source]
   # File lib/httpx/connection/http2.rb
54 def <<(data)
55   @connection << data
56 end
close ()
[show source]
   # File lib/httpx/connection/http2.rb
46 def close
47   @connection.goaway
48 end
consume ()
[show source]
   # File lib/httpx/connection/http2.rb
82 def consume
83   @streams.each do |request, stream|
84     handle(request, stream)
85   end
86 end
empty? ()
[show source]
   # File lib/httpx/connection/http2.rb
50 def empty?
51   @connection.state == :closed || @streams.empty?
52 end
handle_error (ex)
[show source]
   # File lib/httpx/connection/http2.rb
88 def handle_error(ex)
89   @streams.each_key do |request|
90     emit(:error, request, ex)
91   end
92 end
reenqueue! ()
[show source]
   # File lib/httpx/connection/http2.rb
73 def reenqueue!
74   requests = @streams.keys
75   @streams.clear
76   init_connection
77   requests.each do |request|
78     send(request)
79   end
80 end
send (request, **)
[show source]
   # File lib/httpx/connection/http2.rb
58 def send(request, **)
59   if !@handshake_completed ||
60      @connection.active_stream_count >= @max_concurrent_requests
61     @pending << request
62     return
63   end
64   unless (stream = @streams[request])
65     stream = @connection.new_stream
66     handle_stream(stream, request)
67     @streams[request] = stream
68   end
69   handle(request, stream)
70   true
71 end