24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
# File 'lib/rack/show_status.rb', line 24
def call(env)
status, , body = response = @app.call(env)
empty = [CONTENT_LENGTH].to_i <= 0
if (status.to_i >= 400 && empty) || env[RACK_SHOWSTATUS_DETAIL]
req = req = Rack::Request.new(env)
message = Rack::Utils::HTTP_STATUS_CODES[status.to_i] || status.to_s
detail = detail = env[RACK_SHOWSTATUS_DETAIL] || message
html = @template.result(binding)
size = html.bytesize
response[2] = Rack::BodyProxy.new([html]) do
body.close if body.respond_to?(:close)
end
[CONTENT_TYPE] = "text/html"
[CONTENT_LENGTH] = size.to_s
end
response
end
|