Class: FastSend::NaiveEach
- Inherits:
-
Struct
- Object
- Struct
- FastSend::NaiveEach
- Defined in:
- lib/fast_send.rb
Overview
Gets used as a response body wrapper if the server does not support Rack hijacking. The wrapper will be automatically applied by FastSend and will also ensure that all the callbacks get executed.
Instance Attribute Summary collapse
-
#aborted ⇒ Object
Returns the value of attribute aborted.
-
#body_with_each_file ⇒ Object
Returns the value of attribute body_with_each_file.
-
#cleanup ⇒ Object
Returns the value of attribute cleanup.
-
#complete ⇒ Object
Returns the value of attribute complete.
-
#error ⇒ Object
Returns the value of attribute error.
-
#sent ⇒ Object
Returns the value of attribute sent.
-
#started ⇒ Object
Returns the value of attribute started.
Instance Method Summary collapse
Instance Attribute Details
#aborted ⇒ Object
Returns the value of attribute aborted
56 57 58 |
# File 'lib/fast_send.rb', line 56 def aborted @aborted end |
#body_with_each_file ⇒ Object
Returns the value of attribute body_with_each_file
56 57 58 |
# File 'lib/fast_send.rb', line 56 def body_with_each_file @body_with_each_file end |
#cleanup ⇒ Object
Returns the value of attribute cleanup
56 57 58 |
# File 'lib/fast_send.rb', line 56 def cleanup @cleanup end |
#complete ⇒ Object
Returns the value of attribute complete
56 57 58 |
# File 'lib/fast_send.rb', line 56 def complete @complete end |
#error ⇒ Object
Returns the value of attribute error
56 57 58 |
# File 'lib/fast_send.rb', line 56 def error @error end |
#sent ⇒ Object
Returns the value of attribute sent
56 57 58 |
# File 'lib/fast_send.rb', line 56 def sent @sent end |
#started ⇒ Object
Returns the value of attribute started
56 57 58 |
# File 'lib/fast_send.rb', line 56 def started @started end |
Instance Method Details
#each ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/fast_send.rb', line 57 def each written = 0 started.call(0) body_with_each_file.each_file do | file | while data = file.read(64 * 1024) written += data.bytesize yield(data) sent.call(data.bytesize, written) end end complete.call(written) rescue *CLIENT_DISCONNECTS => e aborted.call(e) rescue Exception => e aborted.call(e) error.call(e) raise e ensure cleanup.call(written) end |