vendor/rack/lib/rack/showstatus.rb in relevance-castronaut-0.5.4 vs vendor/rack/lib/rack/showstatus.rb in relevance-castronaut-0.6.0
- old
+ new
@@ -16,13 +16,14 @@
@template = ERB.new(TEMPLATE)
end
def call(env)
status, headers, body = @app.call(env)
+ headers = Utils::HeaderHash.new(headers)
+ empty = headers['Content-Length'].to_i <= 0
# client or server error, or explicit message
- if status.to_i >= 400 &&
- (body.empty? rescue false) || env["rack.showstatus.detail"]
+ if (status.to_i >= 400 && empty) || env["rack.showstatus.detail"]
req = Rack::Request.new(env)
message = Rack::Utils::HTTP_STATUS_CODES[status.to_i] || status.to_s
detail = env["rack.showstatus.detail"] || message
body = @template.result(binding)
size = body.respond_to?(:bytesize) ? body.bytesize : body.size