diff options
Diffstat (limited to 'lib/kcar/response.rb')
-rw-r--r-- | lib/kcar/response.rb | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/lib/kcar/response.rb b/lib/kcar/response.rb index 265c98a..4b90883 100644 --- a/lib/kcar/response.rb +++ b/lib/kcar/response.rb @@ -140,9 +140,13 @@ class Response < Struct.new(:sock, :hdr, :unchunk, :buf, :parser) len -= dst.size yield dst end - while len > 0 - len -= sock.readpartial(len > READ_SIZE ? READ_SIZE : len, dst).size - yield dst + + if len > 0 + begin + len -= sock.readpartial(len > READ_SIZE ? READ_SIZE : len, dst).size + yield dst + end while len > 0 + dst.respond_to?(:clear) ? dst.clear : self.buf = '' end end end |