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
- #close ⇒ Object
-
#connected? ⇒ Boolean
Can we use this connection to make requests?.
- #http1? ⇒ Boolean
- #http2? ⇒ Boolean
-
#initialize(stream, version) ⇒ Connection
constructor
A new instance of Connection.
- #multiplex ⇒ Object
- #peer ⇒ Object
- #read_line ⇒ Object
- #read_line? ⇒ Boolean
- #reusable? ⇒ Boolean
Constructor Details
#initialize(stream, version) ⇒ Connection
Returns a new instance of Connection.
31 32 33 34 35 |
# File 'lib/async/http/protocol/http1/connection.rb', line 31 def initialize(stream, version) super(stream) @version = version end |
Instance Attribute Details
#count ⇒ Object (readonly)
Returns the value of attribute count.
61 62 63 |
# File 'lib/async/http/protocol/http1/connection.rb', line 61 def count @count end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
37 38 39 |
# File 'lib/async/http/protocol/http1/connection.rb', line 37 def version @version end |
Instance Method Details
#close ⇒ Object
77 78 79 80 |
# File 'lib/async/http/protocol/http1/connection.rb', line 77 def close Async.logger.debug(self) {"Closing connection"} super end |
#connected? ⇒ Boolean
Can we use this connection to make requests?
68 69 70 |
# File 'lib/async/http/protocol/http1/connection.rb', line 68 def connected? @stream&.connected? end |
#http1? ⇒ Boolean
39 40 41 |
# File 'lib/async/http/protocol/http1/connection.rb', line 39 def http1? true end |
#http2? ⇒ Boolean
43 44 45 |
# File 'lib/async/http/protocol/http1/connection.rb', line 43 def http2? false end |
#multiplex ⇒ Object
63 64 65 |
# File 'lib/async/http/protocol/http1/connection.rb', line 63 def multiplex 1 end |
#peer ⇒ Object
57 58 59 |
# File 'lib/async/http/protocol/http1/connection.rb', line 57 def peer @stream.io end |
#read_line ⇒ Object
53 54 55 |
# File 'lib/async/http/protocol/http1/connection.rb', line 53 def read_line @stream.read_until(CRLF) or raise EOFError, "Could not read line!" end |
#read_line? ⇒ Boolean
47 48 49 50 51 |
# File 'lib/async/http/protocol/http1/connection.rb', line 47 def read_line? @stream.read_until(CRLF) rescue Errno::ECONNRESET return nil end |
#reusable? ⇒ Boolean
72 73 74 75 |
# File 'lib/async/http/protocol/http1/connection.rb', line 72 def reusable? @stream && !@stream.closed? # !(self.closed? || @stream.closed?) end |