Skip to content

Commit

Permalink
Merge pull request #1640 from ceclinux/minor_refactor
Browse files Browse the repository at this point in the history
minor refactor
  • Loading branch information
namusyaka committed Oct 2, 2020
2 parents 63bcddb + 38fc6b1 commit 8dc1e4a
Showing 1 changed file with 4 additions and 6 deletions.
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]
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

0 comments on commit 8dc1e4a

Please sign in to comment.