Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

minor refactor #1640

Merged
merged 1 commit into from Oct 2, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 4 additions & 6 deletions lib/sinatra/base.rb
Expand Up @@ -188,7 +188,7 @@ def finish
headers["Content-Length"] = body.map(&:bytesize).reduce(0, :+).to_s
end

[status.to_i, headers, result]
[status, headers, result]
namusyaka marked this conversation as resolved.
Show resolved Hide resolved
end

private
Expand All @@ -198,11 +198,11 @@ def calculate_content_length?
end

def drop_content_info?
status.to_i / 100 == 1 or drop_body?
informational? or drop_body?
end

def drop_body?
DROP_BODY_RESPONSES.include?(status.to_i)
DROP_BODY_RESPONSES.include?(status)
end
end

Expand Down Expand Up @@ -1145,16 +1145,14 @@ def handle_exception!(boom)
end
@env['sinatra.error'] = boom

if boom.respond_to? :http_status
if boom.respond_to? :http_status and boom.http_status.between? 400, 599
status(boom.http_status)
elsif settings.use_code? and boom.respond_to? :code and boom.code.between? 400, 599
status(boom.code)
else
status(500)
end

status(500) unless status.between? 400, 599

if server_error?
dump_errors! boom if settings.dump_errors?
raise boom if settings.show_exceptions? and settings.show_exceptions != :after_handler
Expand Down