Permalink
Browse files

Merge pull request #494 from jaseg/showexceptions_accept_headers

Showexceptions accept headers
  • Loading branch information...
rkh committed Mar 23, 2012
2 parents 045ba4e + 0d0a01c commit ebd197d2afc8341d4b93417bd9d7cba8a15ba4a6
Showing with 6 additions and 1 deletion.
  1. +6 −1 lib/sinatra/showexceptions.rb
@@ -22,7 +22,7 @@ def call(env)
rescue Exception => e
errors, env["rack.errors"] = env["rack.errors"], @@eats_errors
- if respond_to?(:prefers_plain_text?) and prefers_plain_text?(env)
+ if prefers_plain_text?(env)
content_type = "text/plain"
body = [dump_exception(e)]
else
@@ -40,6 +40,11 @@ def call(env)
private
+ def prefers_plain_text?(env)
+ !(Request.new(env).preferred_type("text/plain","text/html") == "text/html") &&
+ [/curl/].index{|item| item =~ env["HTTP_USER_AGENT"]}
+ end
+
def frame_class(frame)
if frame.filename =~ /lib\/sinatra.*\.rb/
"framework"

0 comments on commit ebd197d

Please sign in to comment.