Module: Async::HTTP::Body::Reader
Instance Method Summary collapse
-
#body? ⇒ Boolean
Whether there is a body?.
-
#close ⇒ 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.
-
#stop(error = EOFError) ⇒ Object
Immediately stop reading the body.
Instance Method Details
#body? ⇒ Boolean
Whether there is a body?
58 59 60 |
# File 'lib/async/http/body/reader.rb', line 58 def body? @body and !@body.empty? end |
#close ⇒ Object
Close the connection as quickly as possible. Discards body.
53 54 55 |
# File 'lib/async/http/body/reader.rb', line 53 def close self.stop 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.
46 47 48 49 50 |
# File 'lib/async/http/body/reader.rb', line 46 def finish if self.body self.body = self.body.close 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 |
#stop(error = EOFError) ⇒ Object
Immediately stop reading the body. May close the underlying connection. Discards body.
38 39 40 41 42 43 |
# File 'lib/async/http/body/reader.rb', line 38 def stop(error = EOFError) if self.body self.body.stop(error) self.body = nil end end |