Class: Merb::Rack::ContentLength

Inherits:
Middleware show all
Defined in:
lib/merb-core/rack/middleware/content_length.rb

Instance Method Summary collapse

Methods inherited from Middleware

#deferred?, #initialize

Constructor Details

This class inherits a constructor from Merb::Rack::Middleware

Instance Method Details

#call(env) ⇒ Object



5
6
7
8
9
10
11
12
13
14
# File 'lib/merb-core/rack/middleware/content_length.rb', line 5

def call(env)
  status, headers, body = @app.call(env)

  # to_s is because Rack spec expects header
  # values to be iterable and yield strings
  header = 'Content-Length'.freeze
  headers[header] = body.size.to_s unless headers.has_key?(header)

  [status, headers, body]
end