Skip to content

Commit af5d2f5

Browse files
authored
Body should be non-frozen by default. (#103)
1 parent 9501735 commit af5d2f5

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

lib/webrick/httpresponse.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ def initialize(config)
122122
@status = HTTPStatus::RC_OK
123123
@reason_phrase = nil
124124
@http_version = HTTPVersion::convert(@config[:HTTPVersion])
125-
@body = ''
125+
@body = +""
126126
@keep_alive = true
127127
@cookies = []
128128
@request_method = nil
@@ -441,7 +441,7 @@ def check_header(header_value)
441441
# :stopdoc:
442442

443443
def error_body(backtrace, ex, host, port)
444-
@body = +''
444+
@body = +""
445445
@body << <<-_end_of_html_
446446
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
447447
<HTML>

test/webrick/test_httpresponse.rb

+4
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ def setup
2828
@res.keep_alive = true
2929
end
3030

31+
def test_response_body_not_frozen
32+
refute @res.body.frozen?
33+
end
34+
3135
def test_prevent_response_splitting_headers_crlf
3236
res['X-header'] = "malicious\r\nCookie: cracked_indicator_for_test"
3337
io = StringIO.new

0 commit comments

Comments
 (0)