aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/webrick/httpresponse.rb1
-rw-r--r--test/webrick/test_httpresponse.rb7
2 files changed, 8 insertions, 0 deletions
diff --git a/lib/webrick/httpresponse.rb b/lib/webrick/httpresponse.rb
index 9942a59714..ba4494ab74 100644
--- a/lib/webrick/httpresponse.rb
+++ b/lib/webrick/httpresponse.rb
@@ -155,6 +155,7 @@ module WEBrick
# Sets the response header +field+ to +value+
def []=(field, value)
+ @chunked = value.to_s.downcase == 'chunked' if field.downcase == 'transfer-encoding'
@header[field.downcase] = value.to_s
end
diff --git a/test/webrick/test_httpresponse.rb b/test/webrick/test_httpresponse.rb
index 696163ba18..e8c69a1212 100644
--- a/test/webrick/test_httpresponse.rb
+++ b/test/webrick/test_httpresponse.rb
@@ -133,6 +133,13 @@ module WEBrick
assert_equal 0, logger.messages.length
end
+ def test_200_chunked_does_not_set_content_length
+ res.chunked = false
+ res["Transfer-Encoding"] = 'chunked'
+ res.setup_header
+ assert_nil res.header.fetch('content-length', nil)
+ end
+
def test_send_body_io
IO.pipe {|body_r, body_w|
body_w.write 'hello'