class Swee::ContentLength
Public Class Methods
new(app)
click to toggle source
# File lib/swee/middlewaves/content_length.rb, line 4 def initialize(app) @app = app end
Public Instance Methods
call(env)
click to toggle source
# File lib/swee/middlewaves/content_length.rb, line 8 def call(env) status, headers, body = @app.call(env) headers.merge!( { "Content-Length" => calc_length(body) } ) [status, headers, body] end
Private Instance Methods
calc_length(body)
click to toggle source
# File lib/swee/middlewaves/content_length.rb, line 15 def calc_length(body) length = 0 body.each { |part| length += part.bytesize } length end