Skip to content

Commit

Permalink
Fix ActionDispatch::PublicExceptions returning string rack status
Browse files Browse the repository at this point in the history
The status returned in the rack [status, headers, body] array was
a string, which can cause problems with middleware that assumes the
status will be a Fixnum. This likely never surfaced because other
middleware to_i the status returned from downstream apps before
passing it on.
  • Loading branch information
rtomayko authored and pixeltrix committed Mar 23, 2015
1 parent f768cb0 commit 0b81b30
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ def initialize(public_path)
end

def call(env)
status = env["PATH_INFO"][1..-1]
status = env["PATH_INFO"][1..-1].to_i
request = ActionDispatch::Request.new(env)
content_type = request.formats.first
body = { :status => status, :error => Rack::Utils::HTTP_STATUS_CODES.fetch(status.to_i, Rack::Utils::HTTP_STATUS_CODES[500]) }
body = { :status => status, :error => Rack::Utils::HTTP_STATUS_CODES.fetch(status, Rack::Utils::HTTP_STATUS_CODES[500]) }

render(status, content_type, body)
end
Expand Down

0 comments on commit 0b81b30

Please sign in to comment.