Class: Picnic::Server::FixContentLength

Inherits:
Object
  • Object
show all
Defined in:
lib/picnic/server.rb

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ FixContentLength

Returns a new instance of FixContentLength.



87
88
89
# File 'lib/picnic/server.rb', line 87

def initialize(app)
  @app = app
end

Instance Method Details

#call(env) ⇒ Object



91
92
93
94
95
96
97
# File 'lib/picnic/server.rb', line 91

def call(env)
  status, headers, body = @app.call(env)
  if headers.has_key?('Content-Length') && headers['Content-Length'].to_i == 0
    headers['Content-Length'] = body.body.length.to_s
  end
  [status, headers, body]
end