summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authornormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-03-28 08:06:13 +0000
committernormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-03-28 08:06:13 +0000
commitd6c0b3d787b57d5c95156c25076bf222865abe5c (patch)
tree104d3e3bf292cddc4662dbb6a447c24e352b63d5 /lib
parent6676a217f3671e29c7ebac0a90f37385ae58ed5e (diff)
webrick/httpresponse: make ChunkedWrapper copy_stream-compatible
The .write method needs to return the number of bytes written to avoid confusing IO.copy_stream. * lib/webrick/httpresponse.rb (ChunkedWrapper#write): return bytes written (ChunkedWrapper#<<): return self git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62958 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib')
-rw-r--r--lib/webrick/httpresponse.rb9
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/webrick/httpresponse.rb b/lib/webrick/httpresponse.rb
index 5b71facab6..7531a9203e 100644
--- a/lib/webrick/httpresponse.rb
+++ b/lib/webrick/httpresponse.rb
@@ -467,7 +467,7 @@ module WEBrick
end
def write(buf)
- return if buf.empty?
+ return 0 if buf.empty?
socket = @socket
@resp.instance_eval {
size = buf.bytesize
@@ -475,9 +475,14 @@ module WEBrick
socket.write(data)
data.clear
@sent_size += size
+ size
}
end
- alias :<< :write
+
+ def <<(*buf)
+ write(buf)
+ self
+ end
end
# preserved for compatibility with some 3rd-party handlers