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
- #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
-
#viable? ⇒ Boolean
Can we use this connection to make requests?.
Constructor Details
#initialize(stream, version) ⇒ Connection
Returns a new instance of Connection.
33 34 35 36 37 |
# File 'lib/async/http/protocol/http1/connection.rb', line 33 def initialize(stream, version) super(stream) @version = version end |
Instance Attribute Details
#count ⇒ Object (readonly)
Returns the value of attribute count.
63 64 65 |
# File 'lib/async/http/protocol/http1/connection.rb', line 63 def count @count end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
39 40 41 |
# File 'lib/async/http/protocol/http1/connection.rb', line 39 def version @version end |
Instance Method Details
#concurrency ⇒ Object
65 66 67 |
# File 'lib/async/http/protocol/http1/connection.rb', line 65 def concurrency 1 end |
#http1? ⇒ Boolean
41 42 43 |
# File 'lib/async/http/protocol/http1/connection.rb', line 41 def http1? true end |
#http2? ⇒ Boolean
45 46 47 |
# File 'lib/async/http/protocol/http1/connection.rb', line 45 def http2? false end |
#peer ⇒ Object
59 60 61 |
# File 'lib/async/http/protocol/http1/connection.rb', line 59 def peer @stream.io end |
#read_line ⇒ Object
55 56 57 |
# File 'lib/async/http/protocol/http1/connection.rb', line 55 def read_line @stream.read_until(CRLF) or raise EOFError, "Could not read line!" end |
#read_line? ⇒ Boolean
49 50 51 52 53 |
# File 'lib/async/http/protocol/http1/connection.rb', line 49 def read_line? @stream.read_until(CRLF) rescue Errno::ECONNRESET return nil end |
#reusable? ⇒ Boolean
74 75 76 |
# File 'lib/async/http/protocol/http1/connection.rb', line 74 def reusable? @persistent && @stream && !@stream.closed? end |
#viable? ⇒ Boolean
Can we use this connection to make requests?
70 71 72 |
# File 'lib/async/http/protocol/http1/connection.rb', line 70 def viable? @stream&.connected? end |