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
55 56 57 |
# File 'lib/fast_send.rb', line 55 def aborted @aborted end |
#body_with_each_file ⇒ Object
Returns the value of attribute body_with_each_file
55 56 57 |
# File 'lib/fast_send.rb', line 55 def body_with_each_file @body_with_each_file end |
#cleanup ⇒ Object
Returns the value of attribute cleanup
55 56 57 |
# File 'lib/fast_send.rb', line 55 def cleanup @cleanup end |
#complete ⇒ Object
Returns the value of attribute complete
55 56 57 |
# File 'lib/fast_send.rb', line 55 def complete @complete end |
#error ⇒ Object
Returns the value of attribute error
55 56 57 |
# File 'lib/fast_send.rb', line 55 def error @error end |
#sent ⇒ Object
Returns the value of attribute sent
55 56 57 |
# File 'lib/fast_send.rb', line 55 def sent @sent end |
#started ⇒ Object
Returns the value of attribute started
55 56 57 |
# File 'lib/fast_send.rb', line 55 def started @started end |
Instance Method Details
#each ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/fast_send.rb', line 56 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 |