Parent

Included Modules

Class Index [+]

Quicksearch

Rack::Chunked

Middleware that applies chunked transfer encoding to response bodies when the response does not include a Content-Length header.

Public Class Methods

new(app) click to toggle source

(Not documented)

    # File lib/rack/chunked.rb, line 10
10:     def initialize(app)
11:       @app = app
12:     end

Public Instance Methods

call(env) click to toggle source

(Not documented)

    # File lib/rack/chunked.rb, line 14
14:     def call(env)
15:       status, headers, body = @app.call(env)
16:       headers = HeaderHash.new(headers)
17: 
18:       if env['HTTP_VERSION'] == 'HTTP/1.0' ||
19:          STATUS_WITH_NO_ENTITY_BODY.include?(status) ||
20:          headers['Content-Length'] ||
21:          headers['Transfer-Encoding']
22:         [status, headers.to_hash, body]
23:       else
24:         dup.chunk(status, headers, body)
25:       end
26:     end
chunk(status, headers, body) click to toggle source

(Not documented)

    # File lib/rack/chunked.rb, line 28
28:     def chunk(status, headers, body)
29:       @body = body
30:       headers.delete('Content-Length')
31:       headers['Transfer-Encoding'] = 'chunked'
32:       [status, headers.to_hash, self]
33:     end
close() click to toggle source

(Not documented)

    # File lib/rack/chunked.rb, line 45
45:     def close
46:       @body.close if @body.respond_to?(:close)
47:     end
each() click to toggle source

(Not documented)

    # File lib/rack/chunked.rb, line 35
35:     def each
36:       term = "\r\n"
37:       @body.each do |chunk|
38:         size = bytesize(chunk)
39:         next if size == 0
40:         yield [size.to_s(16), term, chunk, term].join
41:       end
42:       yield ["0", term, "", term].join
43:     end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.