Guest User

Untitled

a guest
Jul 16th, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. class Thin::Response # This class specifies it's own each method which yields multiple times.
  2. def each
  3. yield head # Once for the status/headers
  4. if @body.is_a?(String)
  5. yield @body # Again if the response body is a String
  6. else
  7. @body.each { |chunk| yield chunk } # And it enumerates over anything else.
  8. end # This is the place to hook into.
  9. end
  10. end
  11.  
  12. # This is the block getting yielded to!
  13. @response.each do |chunk|
  14. trace { chunk }
  15. send_data chunk
  16. end
Add Comment
Please, Sign In to add comment