Parent

Namespace

Methods

Included Modules

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
# File lib/rack/chunked.rb, line 38
def initialize(app)
  @app = app
end

Public Instance Methods

call(env) click to toggle source
# File lib/rack/chunked.rb, line 42
def call(env)
  status, headers, body = @app.call(env)
  headers = HeaderHash.new(headers)

  if env['HTTP_VERSION'] == 'HTTP/1.0' ||
     STATUS_WITH_NO_ENTITY_BODY.include?(status) ||
     headers['Content-Length'] ||
     headers['Transfer-Encoding']
    [status, headers, body]
  else
    headers.delete('Content-Length')
    headers['Transfer-Encoding'] = 'chunked'
    [status, headers, Body.new(body)]
  end
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.