Module: Async::HTTP::Protocol::HTTP2::Connection
Instance Attribute Summary collapse
-
#count ⇒ Object
readonly
Returns the value of attribute count.
-
#promises ⇒ Object
readonly
Returns the value of attribute promises.
-
#stream ⇒ Object
readonly
Returns the value of attribute stream.
Instance Method Summary collapse
-
#connected? ⇒ Boolean
Can we use this connection to make requests?.
- #http1? ⇒ Boolean
- #http2? ⇒ Boolean
- #initialize ⇒ Object
- #multiplex ⇒ Object
- #peer ⇒ Object
- #read_in_background(task: Task.current) ⇒ Object
- #reusable? ⇒ Boolean
- #start_connection ⇒ Object
- #stop_connection(error) ⇒ Object
- #version ⇒ Object
- #write_frame(frame) ⇒ Object
Instance Attribute Details
#count ⇒ Object (readonly)
Returns the value of attribute count.
97 98 99 |
# File 'lib/async/http/protocol/http2/connection.rb', line 97 def count @count end |
#promises ⇒ Object (readonly)
Returns the value of attribute promises.
91 92 93 |
# File 'lib/async/http/protocol/http2/connection.rb', line 91 def promises @promises end |
#stream ⇒ Object (readonly)
Returns the value of attribute stream.
50 51 52 |
# File 'lib/async/http/protocol/http2/connection.rb', line 50 def stream @stream end |
Instance Method Details
#connected? ⇒ Boolean
Can we use this connection to make requests?
104 105 106 |
# File 'lib/async/http/protocol/http2/connection.rb', line 104 def connected? @stream.connected? end |
#http1? ⇒ Boolean
52 53 54 |
# File 'lib/async/http/protocol/http2/connection.rb', line 52 def http1? false end |
#http2? ⇒ Boolean
56 57 58 |
# File 'lib/async/http/protocol/http2/connection.rb', line 56 def http2? true end |
#initialize ⇒ Object
40 41 42 43 44 45 46 47 48 |
# File 'lib/async/http/protocol/http2/connection.rb', line 40 def initialize(*) super @count = 0 @reader = nil # Writing multiple frames at the same time can cause odd problems if frames are only partially written. So we use a semaphore to ensure frames are written in their entirety. @write_frame_guard = Async::Semaphore.new(1) end |
#multiplex ⇒ Object
99 100 101 |
# File 'lib/async/http/protocol/http2/connection.rb', line 99 def multiplex @remote_settings.maximum_concurrent_streams end |
#peer ⇒ Object
93 94 95 |
# File 'lib/async/http/protocol/http2/connection.rb', line 93 def peer @stream.io end |
#read_in_background(task: Task.current) ⇒ Object
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/async/http/protocol/http2/connection.rb', line 75 def read_in_background(task: Task.current) task.async do |nested_task| nested_task.annotate("#{version} reading data for #{self.class}") begin while !self.closed? self.read_frame end rescue EOFError, Async::Wrapper::Cancelled # Stream closed. ensure stop_connection($!) end end end |
#reusable? ⇒ Boolean
108 109 110 |
# File 'lib/async/http/protocol/http2/connection.rb', line 108 def reusable? !(self.closed? || @stream.closed?) end |
#start_connection ⇒ Object
60 61 62 |
# File 'lib/async/http/protocol/http2/connection.rb', line 60 def start_connection @reader ||= read_in_background end |
#stop_connection(error) ⇒ Object
64 65 66 |
# File 'lib/async/http/protocol/http2/connection.rb', line 64 def stop_connection(error) @reader = nil end |
#version ⇒ Object
112 113 114 |
# File 'lib/async/http/protocol/http2/connection.rb', line 112 def version VERSION end |
#write_frame(frame) ⇒ Object
68 69 70 71 72 73 |
# File 'lib/async/http/protocol/http2/connection.rb', line 68 def write_frame(frame) # We don't want to write multiple frames at the same time. @write_frame_guard.acquire do super end end |