aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-03-29 03:45:32 +0000
committerhsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-03-29 03:45:32 +0000
commitc2355aefc99a03b8f42d2fca44c08983bdbdd087 (patch)
tree8b9f08252c729480a03669d6ccc1840b92a46c1b
parent7504be10efbc6002cdfe205c05a7f2690c368296 (diff)
downloadruby-c2355aefc99a03b8f42d2fca44c08983bdbdd087.tar.gz
* lib/webrick/httpresponse.rb: Move error_body to method. It allow to
override the body more easily. [fix GH-1307] * test/webrick/test_httpresponse.rb: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54346 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog6
-rw-r--r--lib/webrick/httpresponse.rb12
-rw-r--r--test/webrick/test_httpresponse.rb10
3 files changed, 24 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index 9aff658a77..b3e54ed4f5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Tue Mar 29 12:45:18 2016 Laurent Arnoud <laurent@spkdev.net>
+
+ * lib/webrick/httpresponse.rb: Move error_body to method. It allow to
+ override the body more easily. [fix GH-1307]
+ * test/webrick/test_httpresponse.rb: ditto.
+
Tue Mar 29 06:40:53 2016 Nobuyoshi Nakada <nobu@ruby-lang.org>
* error.c (rb_compile_err_append): rb_thread_t::base_block is no
diff --git a/lib/webrick/httpresponse.rb b/lib/webrick/httpresponse.rb
index 5fd54b77c7..eae14d6597 100644
--- a/lib/webrick/httpresponse.rb
+++ b/lib/webrick/httpresponse.rb
@@ -352,6 +352,14 @@ module WEBrick
host, port = @config[:ServerName], @config[:Port]
end
+ error_body(backtrace, ex, host, port)
+ end
+
+ private
+
+ # :stopdoc:
+
+ def error_body(backtrace, ex, host, port)
@body = ''
@body << <<-_end_of_html_
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
@@ -381,10 +389,6 @@ module WEBrick
_end_of_html_
end
- private
-
- # :stopdoc:
-
def send_body_io(socket)
begin
if @request_method == "HEAD"
diff --git a/test/webrick/test_httpresponse.rb b/test/webrick/test_httpresponse.rb
index b3f06cd469..d97a65b5db 100644
--- a/test/webrick/test_httpresponse.rb
+++ b/test/webrick/test_httpresponse.rb
@@ -146,5 +146,15 @@ module WEBrick
}
assert_equal 0, logger.messages.length
end
+
+ def test_set_error
+ status = 400
+ message = 'missing attribute'
+ @res.status = status
+ error = WEBrick::HTTPStatus[status].new(message)
+ body = @res.set_error(error)
+ assert_match(/#{@res.reason_phrase}/, body)
+ assert_match(/#{message}/, body)
+ end
end
end