123456789_123456789_123456789_123456789_123456789_

Class: ActionController::Streaming::Body

Do not use. This class is for internal use only.
Relationships & Source Files
Inherits: Object
Defined in: actionpack/lib/action_controller/metal/streaming.rb

Constant Summary

Class Method Summary

Instance Method Summary

  • #close

    Close the response body if the response body supports it.

  • #each {|TAIL| ... }

    For each element yielded by the response body, yield the element in chunked encoding.

Constructor Details

.new(body) ⇒ Body

Store the response body to be chunked.

[ GitHub ]

  
# File 'actionpack/lib/action_controller/metal/streaming.rb', line 212

def initialize(body)
  @body = body
end

Instance Method Details

#close

Close the response body if the response body supports it.

[ GitHub ]

  
# File 'actionpack/lib/action_controller/metal/streaming.rb', line 231

def close
  @body.close if @body.respond_to?(:close)
end

#each {|TAIL| ... }

For each element yielded by the response body, yield the element in chunked encoding.

Yields:

[ GitHub ]

  
# File 'actionpack/lib/action_controller/metal/streaming.rb', line 218

def each(&block)
  term = TERM
  @body.each do |chunk|
    size = chunk.bytesize
    next if size == 0

    yield [size.to_s(16), term, chunk.b, term].join
  end
  yield TAIL
  yield term
end