mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
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:
parent
6676a217f3
commit
d6c0b3d787
1 changed files with 7 additions and 2 deletions
|
@ -467,7 +467,7 @@ module WEBrick
|
||||||
end
|
end
|
||||||
|
|
||||||
def write(buf)
|
def write(buf)
|
||||||
return if buf.empty?
|
return 0 if buf.empty?
|
||||||
socket = @socket
|
socket = @socket
|
||||||
@resp.instance_eval {
|
@resp.instance_eval {
|
||||||
size = buf.bytesize
|
size = buf.bytesize
|
||||||
|
@ -475,9 +475,14 @@ module WEBrick
|
||||||
socket.write(data)
|
socket.write(data)
|
||||||
data.clear
|
data.clear
|
||||||
@sent_size += size
|
@sent_size += size
|
||||||
|
size
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
alias :<< :write
|
|
||||||
|
def <<(*buf)
|
||||||
|
write(buf)
|
||||||
|
self
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# preserved for compatibility with some 3rd-party handlers
|
# preserved for compatibility with some 3rd-party handlers
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue