Class: Async::HTTP::Protocol::HTTP1::Connection
- Inherits:
-
Protocol::HTTP1::Connection
- Object
- Protocol::HTTP1::Connection
- Async::HTTP::Protocol::HTTP1::Connection
- Defined in:
- lib/async/http/protocol/http1/connection.rb
Instance Attribute Summary collapse
-
#count ⇒ Object
readonly
Returns the value of attribute count.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Instance Method Summary collapse
- #as_json ⇒ Object
- #concurrency ⇒ Object
- #http1? ⇒ Boolean
- #http2? ⇒ Boolean
-
#initialize(stream, version) ⇒ Connection
constructor
A new instance of Connection.
- #peer ⇒ Object
- #read_line ⇒ Object
- #read_line? ⇒ Boolean
- #reusable? ⇒ Boolean
- #to_json ⇒ Object
- #to_s ⇒ Object
-
#viable? ⇒ Boolean
Can we use this connection to make requests?.
Constructor Details
#initialize(stream, version) ⇒ Connection
Returns a new instance of Connection.
16 17 18 19 20 |
# File 'lib/async/http/protocol/http1/connection.rb', line 16 def initialize(stream, version) super(stream) @version = version end |
Instance Attribute Details
#count ⇒ Object (readonly)
Returns the value of attribute count.
58 59 60 |
# File 'lib/async/http/protocol/http1/connection.rb', line 58 def count @count end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
34 35 36 |
# File 'lib/async/http/protocol/http1/connection.rb', line 34 def version @version end |
Instance Method Details
#as_json ⇒ Object
26 27 28 |
# File 'lib/async/http/protocol/http1/connection.rb', line 26 def as_json(...) to_s end |
#concurrency ⇒ Object
60 61 62 |
# File 'lib/async/http/protocol/http1/connection.rb', line 60 def concurrency 1 end |
#http1? ⇒ Boolean
36 37 38 |
# File 'lib/async/http/protocol/http1/connection.rb', line 36 def http1? true end |
#http2? ⇒ Boolean
40 41 42 |
# File 'lib/async/http/protocol/http1/connection.rb', line 40 def http2? false end |
#peer ⇒ Object
54 55 56 |
# File 'lib/async/http/protocol/http1/connection.rb', line 54 def peer @stream.io end |
#read_line ⇒ Object
50 51 52 |
# File 'lib/async/http/protocol/http1/connection.rb', line 50 def read_line @stream.read_until(CRLF) or raise EOFError, "Could not read line!" end |
#read_line? ⇒ Boolean
44 45 46 47 48 |
# File 'lib/async/http/protocol/http1/connection.rb', line 44 def read_line? @stream.read_until(CRLF) rescue Errno::ECONNRESET return nil end |
#reusable? ⇒ Boolean
69 70 71 |
# File 'lib/async/http/protocol/http1/connection.rb', line 69 def reusable? @persistent && @stream && !@stream.closed? end |
#to_json ⇒ Object
30 31 32 |
# File 'lib/async/http/protocol/http1/connection.rb', line 30 def to_json(...) as_json.to_json(...) end |
#to_s ⇒ Object
22 23 24 |
# File 'lib/async/http/protocol/http1/connection.rb', line 22 def to_s "\#<#{self.class} negotiated #{@version}, #{@state}>" end |
#viable? ⇒ Boolean
Can we use this connection to make requests?
65 66 67 |
# File 'lib/async/http/protocol/http1/connection.rb', line 65 def viable? self.idle? && @stream&.readable? end |