Module: Async::HTTP::Body::Reader
Instance Method Summary collapse
-
#body? ⇒ Boolean
Whether there is a body?.
-
#close(error = nil) ⇒ Object
Close the connection as quickly as possible.
-
#each(&block) ⇒ Object
Read chunks from the body.
-
#finish ⇒ Object
Gracefully finish reading the body.
-
#read ⇒ Object
Reads the entire request/response body.
Instance Method Details
#body? ⇒ Boolean
Whether there is a body?
53 54 55 |
# File 'lib/async/http/body/reader.rb', line 53 def body? @body and !@body.empty? end |
#close(error = nil) ⇒ Object
Close the connection as quickly as possible. Discards body. May close the underlying connection if necessary to terminate the stream.
45 46 47 48 49 50 |
# File 'lib/async/http/body/reader.rb', line 45 def close(error = nil) if self.body self.body.close(error) self.body = nil end end |
#each(&block) ⇒ Object
Read chunks from the body.
26 27 28 |
# File 'lib/async/http/body/reader.rb', line 26 def each(&block) self.body.each(&block) end |
#finish ⇒ Object
Gracefully finish reading the body. This will buffer the remainder of the body.
38 39 40 41 42 |
# File 'lib/async/http/body/reader.rb', line 38 def finish if self.body self.body = self.body.finish end end |
#read ⇒ Object
Reads the entire request/response body.
31 32 33 34 35 |
# File 'lib/async/http/body/reader.rb', line 31 def read if self.body self.body.join end end |