Class: Swee::ContentLength

Inherits:
Object show all
Defined in:
lib/swee/middlewaves/content_length.rb

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ ContentLength

Returns a new instance of ContentLength.



5
6
7
# File 'lib/swee/middlewaves/content_length.rb', line 5

def initialize(app)
  @app = app
end

Instance Method Details

#call(env) ⇒ Object



9
10
11
12
13
# File 'lib/swee/middlewaves/content_length.rb', line 9

def call(env)
  status, headers, body = @app.call(env)
  headers.merge!( { "Content-Length" => calc_length(body) } )
  [status, headers, body]
end