Class: Async::HTTP::Protocol::HTTP1::Connection
- Inherits:
-
HTTP::Protocol::HTTP1::Connection
- Object
- HTTP::Protocol::HTTP1::Connection
- Async::HTTP::Protocol::HTTP1::Connection
- 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.
-
#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 ⇒ Object
- #read_remainder_body ⇒ Object
- #read_tunnel_body ⇒ Object
- #reusable? ⇒ Boolean
- #write_body_head(body) ⇒ Object
- #write_empty_body(body) ⇒ Object
Constructor Details
#initialize(stream, version) ⇒ Connection
Returns a new instance of Connection.
34 35 36 37 38 |
# File 'lib/async/http/protocol/http1/connection.rb', line 34 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 |
#stream ⇒ Object (readonly)
Returns the value of attribute stream.
44 45 46 |
# File 'lib/async/http/protocol/http1/connection.rb', line 44 def stream @stream end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
40 41 42 |
# File 'lib/async/http/protocol/http1/connection.rb', line 40 def version @version end |
Instance Method Details
#close ⇒ Object
79 80 81 82 83 |
# File 'lib/async/http/protocol/http1/connection.rb', line 79 def close Async.logger.debug(self) {"Closing connection"} @stream.close end |
#connected? ⇒ Boolean
Can we use this connection to make requests?
70 71 72 |
# File 'lib/async/http/protocol/http1/connection.rb', line 70 def connected? @stream.connected? end |
#hijack ⇒ Async::Wrapper
Returns the underlying non-blocking IO.
51 52 53 54 55 56 57 |
# File 'lib/async/http/protocol/http1/connection.rb', line 51 def hijack @persistent = false @stream.flush return @stream.io end |
#multiplex ⇒ Object
65 66 67 |
# File 'lib/async/http/protocol/http1/connection.rb', line 65 def multiplex 1 end |
#peer ⇒ Object
59 60 61 |
# File 'lib/async/http/protocol/http1/connection.rb', line 59 def peer @stream.io end |
#read_chunked_body ⇒ Object
97 98 99 |
# File 'lib/async/http/protocol/http1/connection.rb', line 97 def read_chunked_body Body::Chunked.new(self) end |
#read_fixed_body(length) ⇒ Object
101 102 103 |
# File 'lib/async/http/protocol/http1/connection.rb', line 101 def read_fixed_body(length) Body::Fixed.new(@stream, length) end |
#read_line ⇒ Object
46 47 48 |
# File 'lib/async/http/protocol/http1/connection.rb', line 46 def read_line @stream.read_until(CRLF) or raise EOFError end |
#read_remainder_body ⇒ Object
109 110 111 |
# File 'lib/async/http/protocol/http1/connection.rb', line 109 def read_remainder_body Body::Remainder.new(@stream) end |
#read_tunnel_body ⇒ Object
105 106 107 |
# File 'lib/async/http/protocol/http1/connection.rb', line 105 def read_tunnel_body read_remainder_body end |
#reusable? ⇒ Boolean
74 75 76 77 |
# File 'lib/async/http/protocol/http1/connection.rb', line 74 def reusable? !@stream.closed? # !(self.closed? || @stream.closed?) end |
#write_body_head(body) ⇒ Object
91 92 93 94 95 |
# File 'lib/async/http/protocol/http1/connection.rb', line 91 def write_body_head(body) super(body) body.close if body end |
#write_empty_body(body) ⇒ Object
85 86 87 88 89 |
# File 'lib/async/http/protocol/http1/connection.rb', line 85 def write_empty_body(body) super(body) body.close if body end |