diff options
author | drbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-08-07 18:38:39 +0000 |
---|---|---|
committer | drbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-08-07 18:38:39 +0000 |
commit | 9dff71ad78bce48d61a5f16a59a9f666ceed6350 (patch) | |
tree | 8471468a33aa9d64df734587dd2f4e571d8c490d /lib/webrick | |
parent | d5ecd17aeedae091ddda0f1a26c67f9902243ab1 (diff) | |
download | ruby-9dff71ad78bce48d61a5f16a59a9f666ceed6350.tar.gz |
* lib/webrick/httpresponse.rb: Allow #body to be an IO-like object
that responds to #readpartial and #read.
[ruby-trunk - Feature #8155]
* NEWS: NEWS for above
* test/webrick/test_httpresponse.rb: Tests for above.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42427 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/webrick')
-rw-r--r-- | lib/webrick/httpresponse.rb | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/lib/webrick/httpresponse.rb b/lib/webrick/httpresponse.rb index 8e3eb39a31..044b8dfcaf 100644 --- a/lib/webrick/httpresponse.rb +++ b/lib/webrick/httpresponse.rb @@ -47,7 +47,8 @@ module WEBrick attr_accessor :reason_phrase ## - # Body may be a String or IO subclass. + # Body may be a String or IO-like object that responds to #read and + # #readpartial. attr_accessor :body @@ -299,9 +300,10 @@ module WEBrick # Sends the body on +socket+ def send_body(socket) # :nodoc: - case @body - when IO then send_body_io(socket) - else send_body_string(socket) + if @body.respond_to? :readpartial then + send_body_io(socket) + else + send_body_string(socket) end end |