19: def call(env)
20: status, headers, body = @app.call(env)
21: headers = Utils::HeaderHash.new(headers)
22: empty = headers['Content-Length'].to_i <= 0
23:
24:
25: if (status.to_i >= 400 && empty) || env["rack.showstatus.detail"]
26: req = Rack::Request.new(env)
27: message = Rack::Utils::HTTP_STATUS_CODES[status.to_i] || status.to_s
28: detail = env["rack.showstatus.detail"] || message
29: body = @template.result(binding)
30: size = Rack::Utils.bytesize(body)
31: [status, headers.merge("Content-Type" => "text/html", "Content-Length" => size.to_s), [body]]
32: else
33: [status, headers, body]
34: end
35: end