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?.
-
#hijack! ⇒ Async::Wrapper
The underlying non-blocking IO.
-
#initialize(stream, version) ⇒ Connection
constructor
A new instance of Connection.
- #multiplex ⇒ Object
- #peer ⇒ Object
- #read_chunked_body ⇒ Object
- #read_fixed_body(length) ⇒ Object
- #read_line? ⇒ Boolean
- #read_remainder_body ⇒ Object
- #reusable? ⇒ Boolean
Constructor Details
#initialize(stream, version) ⇒ Connection
Returns a new instance of Connection.
35 36 37 38 39 |
# File 'lib/async/http/protocol/http1/connection.rb', line 35 def initialize(stream, version) super(stream) @version = version end |
Instance Attribute Details
#count ⇒ Object (readonly)
Returns the value of attribute count.
60 61 62 |
# File 'lib/async/http/protocol/http1/connection.rb', line 60 def count @count end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
41 42 43 |
# File 'lib/async/http/protocol/http1/connection.rb', line 41 def version @version end |
Instance Method Details
#close ⇒ Object
76 77 78 79 80 |
# File 'lib/async/http/protocol/http1/connection.rb', line 76 def close Async.logger.debug(self) {"Closing connection"} @stream.close end |
#connected? ⇒ Boolean
Can we use this connection to make requests?
67 68 69 |
# File 'lib/async/http/protocol/http1/connection.rb', line 67 def connected? @stream.connected? end |
#hijack! ⇒ Async::Wrapper
Returns the underlying non-blocking IO.
48 49 50 51 52 53 54 |
# File 'lib/async/http/protocol/http1/connection.rb', line 48 def hijack! @persistent = false @stream.flush return @stream.io end |
#multiplex ⇒ Object
62 63 64 |
# File 'lib/async/http/protocol/http1/connection.rb', line 62 def multiplex 1 end |
#peer ⇒ Object
56 57 58 |
# File 'lib/async/http/protocol/http1/connection.rb', line 56 def peer @stream.io end |
#read_chunked_body ⇒ Object
82 83 84 |
# File 'lib/async/http/protocol/http1/connection.rb', line 82 def read_chunked_body Body::Chunked.new(self) end |
#read_fixed_body(length) ⇒ Object
86 87 88 |
# File 'lib/async/http/protocol/http1/connection.rb', line 86 def read_fixed_body(length) Body::Fixed.new(@stream, length) end |
#read_line? ⇒ Boolean
43 44 45 |
# File 'lib/async/http/protocol/http1/connection.rb', line 43 def read_line? @stream.read_until(CRLF) end |
#read_remainder_body ⇒ Object
90 91 92 |
# File 'lib/async/http/protocol/http1/connection.rb', line 90 def read_remainder_body Body::Remainder.new(@stream) end |
#reusable? ⇒ Boolean
71 72 73 74 |
# File 'lib/async/http/protocol/http1/connection.rb', line 71 def reusable? !@stream.closed? # !(self.closed? || @stream.closed?) end |