class Rack::Chunked::Body - rack-1.6.2 Documentation

# class Rack::Chunked::Body

A body wrapper that emits chunked responses

### Constants

TAIL
TERM

### Public Class Methods

new(body) click to toggle source

    # File lib/rack/chunked.rb, line 17
    def initialize(body)
      @body = body
    end

### Public Instance Methods

close() click to toggle source

    # File lib/rack/chunked.rb, line 33
    def close
      @body.close if @body.respond_to?(:close)
    end

each() { |[size, term, chunk, term].join| ... } click to toggle source

    # File lib/rack/chunked.rb, line 21
    def each
      term = TERM
      @body.each do |chunk|
        size = bytesize(chunk)
        next if size == 0

        chunk = chunk.dup.force_encoding(Encoding::BINARY) if chunk.respond_to?(:force_encoding)
        yield [size.to_s(16), term, chunk, term].join
      end
      yield TAIL
    end