class Rack::Chunked::Body
A body wrapper that emits chunked responses.
Constants
- TAIL
- TERM
Public Class Methods
new(body)
click to toggle source
Store the response body to be chunked.
# File lib/rack/chunked.rb, line 29 def initialize(body) @body = body end
Public Instance Methods
close()
click to toggle source
Close the response body if the response body supports it.
# File lib/rack/chunked.rb, line 49 def close @body.close if @body.respond_to?(:close) end
each() { |[size, term, b, term].join| ... }
click to toggle source
For each element yielded by the response body, yield the element in chunked encoding.
# File lib/rack/chunked.rb, line 35 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_trailers(&block) yield term end
Private Instance Methods
yield_trailers()
click to toggle source
Do nothing as this class does not support trailer headers.
# File lib/rack/chunked.rb, line 56 def yield_trailers end