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
This commit is contained in:
normal 2018-03-28 08:06:13 +00:00
Родитель 6676a217f3
Коммит d6c0b3d787
1 изменённых файлов: 7 добавлений и 2 удалений

Просмотреть файл

@ -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