diff options
author | Eric Wong <normalperson@yhbt.net> | 2009-11-08 01:57:14 -0800 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2009-11-08 02:49:14 -0800 |
commit | 8cd6f4d94503a568501b6e24bb785a8e002720c9 (patch) | |
tree | 82c6c2df9ec84038e55e08444a2b505f076ac031 /lib/rainbows/revactor | |
parent | b4f1271320d38e83141dbb38463c3a368661aef7 (diff) | |
download | rainbows-8cd6f4d94503a568501b6e24bb785a8e002720c9.tar.gz |
Explicitly requested short reads may cause too much data to be returned, which would be bad and potentially break the application. We need to ensure proper IO#readpartial-like semantics in both of these models.
Diffstat (limited to 'lib/rainbows/revactor')
-rw-r--r-- | lib/rainbows/revactor/tee_input.rb | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/rainbows/revactor/tee_input.rb b/lib/rainbows/revactor/tee_input.rb index 92effb4..b8042ad 100644 --- a/lib/rainbows/revactor/tee_input.rb +++ b/lib/rainbows/revactor/tee_input.rb @@ -24,6 +24,11 @@ module Rainbows begin if parser.filter_body(dst, buf << socket.read).nil? @tmp.write(dst) + diff = dst.size - length + if diff > 0 + dst.replace(dst[0,length]) + @tmp.seek(-diff, IO::SEEK_CUR) + end return dst end rescue EOFError |