Module: Async::HTTP::Protocol::HTTP1::Connection
- Included in:
- Async::HTTP::Protocol::HTTP10::Client, Async::HTTP::Protocol::HTTP10::Server, Async::HTTP::Protocol::HTTP11::Client, Async::HTTP::Protocol::HTTP11::Server
- Defined in:
- lib/async/http/protocol/http1/connection.rb
Constant Summary collapse
- CRLF =
"\r\n"
Instance Attribute Summary collapse
-
#count ⇒ Object
readonly
Returns the value of attribute count.
-
#stream ⇒ Object
readonly
Returns the value of attribute stream.
Instance Method Summary collapse
- #close ⇒ Object
-
#connected? ⇒ Boolean
Can we use this connection to make requests?.
-
#hijack ⇒ Async::Wrapper
The underlying non-blocking IO.
- #multiplex ⇒ Object
- #peer ⇒ Object
- #read_chunked_body ⇒ Object
- #read_fixed_body(length) ⇒ Object
- #read_line ⇒ Object
- #read_remainder_body ⇒ Object
- #read_tunnel_body ⇒ Object
- #reusable? ⇒ Boolean
Instance Attribute Details
#count ⇒ Object (readonly)
Returns the value of attribute count.
53 54 55 |
# File 'lib/async/http/protocol/http1/connection.rb', line 53 def count @count end |
#stream ⇒ Object (readonly)
Returns the value of attribute stream.
34 35 36 |
# File 'lib/async/http/protocol/http1/connection.rb', line 34 def stream @stream end |
Instance Method Details
#close ⇒ Object
69 70 71 72 73 |
# File 'lib/async/http/protocol/http1/connection.rb', line 69 def close Async.logger.debug(self) {"Closing connection"} @stream.close end |
#connected? ⇒ Boolean
Can we use this connection to make requests?
60 61 62 |
# File 'lib/async/http/protocol/http1/connection.rb', line 60 def connected? @stream.connected? end |
#hijack ⇒ Async::Wrapper
Returns the underlying non-blocking IO.
41 42 43 44 45 46 47 |
# File 'lib/async/http/protocol/http1/connection.rb', line 41 def hijack @persistent = false @stream.flush return @stream.io end |
#multiplex ⇒ Object
55 56 57 |
# File 'lib/async/http/protocol/http1/connection.rb', line 55 def multiplex 1 end |
#peer ⇒ Object
49 50 51 |
# File 'lib/async/http/protocol/http1/connection.rb', line 49 def peer @stream.io end |
#read_chunked_body ⇒ Object
75 76 77 |
# File 'lib/async/http/protocol/http1/connection.rb', line 75 def read_chunked_body Body::Chunked.new(self) end |
#read_fixed_body(length) ⇒ Object
79 80 81 |
# File 'lib/async/http/protocol/http1/connection.rb', line 79 def read_fixed_body(length) Body::Fixed.new(@stream, length) end |
#read_line ⇒ Object
36 37 38 |
# File 'lib/async/http/protocol/http1/connection.rb', line 36 def read_line @stream.read_until(CRLF) or raise EOFError end |
#read_remainder_body ⇒ Object
87 88 89 |
# File 'lib/async/http/protocol/http1/connection.rb', line 87 def read_remainder_body Body::Remainder.new(@stream) end |
#read_tunnel_body ⇒ Object
83 84 85 |
# File 'lib/async/http/protocol/http1/connection.rb', line 83 def read_tunnel_body read_remainder_body end |
#reusable? ⇒ Boolean
64 65 66 67 |
# File 'lib/async/http/protocol/http1/connection.rb', line 64 def reusable? !@stream.closed? # !(self.closed? || @stream.closed?) end |