Class: Rack::Chunked::Body

Inherits:
Object
  • Object
show all
Includes:
Utils
Defined in:
rack/rack/chunked.rb

Overview

A body wrapper that emits chunked responses

Constant Summary

TERM =
"\r\n"
TAIL =
"0#{TERM}#{TERM}"

Class Attribute Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (Body) initialize(body)

Returns a new instance of Body



17
18
19
# File 'rack/rack/chunked.rb', line 17

def initialize(body)
  @body = body
end

Class Attribute Details

+ (void) key_space_limit Originally defined in module Utils

Returns the value of attribute key_space_limit

Instance Method Details

- (void) close



33
34
35
# File 'rack/rack/chunked.rb', line 33

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

- (void) each {|TAIL| ... }

Yields:



21
22
23
24
25
26
27
28
29
30
31
# File 'rack/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