Rack::ShowStatus catches all empty responses and replaces them with a site explaining the error.
Additional details can be put into rack.showstatus.detail and will be shown as HTML. If such details exist, the error page is always rendered, even if the reply was not empty.
# File lib/rack/showstatus.rb, line 19 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: # client or server error, or explicit message 25: if (status.to_i >= 400 && empty) || env["rack.showstatus.detail"] 26: # This double assignment is to prevent an "unused variable" warning on 27: # Ruby 1.9.3. Yes, it is dumb, but I don't like Ruby yelling at me. 28: req = req = Rack::Request.new(env) 29: 30: message = Rack::Utils::HTTP_STATUS_CODES[status.to_i] || status.to_s 31: 32: # This double assignment is to prevent an "unused variable" warning on 33: # Ruby 1.9.3. Yes, it is dumb, but I don't like Ruby yelling at me. 34: detail = detail = env["rack.showstatus.detail"] || message 35: 36: body = @template.result(binding) 37: size = Rack::Utils.bytesize(body) 38: [status, headers.merge("Content-Type" => "text/html", "Content-Length" => size.to_s), [body]] 39: else 40: [status, headers, body] 41: end 42: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.