aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2012-10-01 21:31:34 -0700
committerRafael Mendonça França <rafaelmfranca@gmail.com>2012-10-01 21:31:34 -0700
commit0d41d6956f3dda7e8eb133b623bcfd6ad1eb41a1 (patch)
tree446a72d24555c382f2d07d7743f245d5f5cb7a9f /actionpack
parentcfc0ca0516d818bffdd5959ebe415362965d2de0 (diff)
parent561edbe71ff70abc3c0c63c6c05770b434f9b0a9 (diff)
downloadrails-0d41d6956f3dda7e8eb133b623bcfd6ad1eb41a1.tar.gz
rails-0d41d6956f3dda7e8eb133b623bcfd6ad1eb41a1.tar.bz2
rails-0d41d6956f3dda7e8eb133b623bcfd6ad1eb41a1.zip
Merge pull request #7636 from steveklabnik/issue_5660
Fixes issue #5660: Failsafe exception returns text/html and text/plain.
Diffstat (limited to 'actionpack')
-rw-r--r--actionpack/CHANGELOG.md2
-rw-r--r--actionpack/lib/action_dispatch/middleware/show_exceptions.rb6
-rw-r--r--actionpack/test/controller/show_exceptions_test.rb16
3 files changed, 21 insertions, 3 deletions
diff --git a/actionpack/CHANGELOG.md b/actionpack/CHANGELOG.md
index 689870fdd2..5a5c4b33f1 100644
--- a/actionpack/CHANGELOG.md
+++ b/actionpack/CHANGELOG.md
@@ -1,5 +1,7 @@
## Rails 4.0.0 (unreleased) ##
+* Failsafe exception returns text/plain. *Steve Klabnik*
+
* Remove actionpack's rack-cache dependency and declare the
dependency in the Gemfile.
diff --git a/actionpack/lib/action_dispatch/middleware/show_exceptions.rb b/actionpack/lib/action_dispatch/middleware/show_exceptions.rb
index ab740a0190..402f29cd76 100644
--- a/actionpack/lib/action_dispatch/middleware/show_exceptions.rb
+++ b/actionpack/lib/action_dispatch/middleware/show_exceptions.rb
@@ -15,11 +15,11 @@ module ActionDispatch
# If any exception happens inside the exceptions app, this middleware
# catches the exceptions and returns a FAILSAFE_RESPONSE.
class ShowExceptions
- FAILSAFE_RESPONSE = [500, {'Content-Type' => 'text/html'},
- ["<html><body><h1>500 Internal Server Error</h1>" <<
+ FAILSAFE_RESPONSE = [500, { 'Content-Type' => 'text/plain' },
+ ["500 Internal Server Error\n" <<
"If you are the administrator of this website, then please read this web " <<
"application's log file and/or the web server's log file to find out what " <<
- "went wrong.</body></html>"]]
+ "went wrong."]]
def initialize(app, exceptions_app)
@app = app
diff --git a/actionpack/test/controller/show_exceptions_test.rb b/actionpack/test/controller/show_exceptions_test.rb
index 351b9c4cfa..ab1bd0e3b6 100644
--- a/actionpack/test/controller/show_exceptions_test.rb
+++ b/actionpack/test/controller/show_exceptions_test.rb
@@ -93,4 +93,20 @@ module ShowExceptions
assert_equal 'text/html', response.content_type.to_s
end
end
+
+ class ShowFailsafeExceptionsTest < ActionDispatch::IntegrationTest
+ def test_render_failsafe_exception
+ @app = ShowExceptionsOverridenController.action(:boom)
+ @exceptions_app = @app.instance_variable_get(:@exceptions_app)
+ @app.instance_variable_set(:@exceptions_app, nil)
+ $stderr = StringIO.new
+
+ get '/', {}, 'HTTP_ACCEPT' => 'text/json'
+ assert_response :internal_server_error
+ assert_equal 'text/plain', response.content_type.to_s
+
+ @app.instance_variable_set(:@exceptions_app, @exceptions_app)
+ $stderr = STDERR
+ end
+ end
end