lib/kcar/response.rb in kcar-0.3.0 vs lib/kcar/response.rb in kcar-0.3.1

- old
+ new

@@ -61,25 +61,18 @@ # this method allows our Kcar::Response object to be used as a Rack response # body. It may only be called once (usually by a Rack server) as it streams # the response body off the our socket object. def each - if @parser.body_eof? - return - end + return if @parser.body_eof? if @unchunk @parser.chunked? ? each_unchunk { |x| yield x } : each_identity { |x| yield x } else - if @parser.keepalive? - @parser.chunked? ? each_rechunk { |x| yield x } : - each_identity { |x| yield x } - else - each_until_eof { |x| yield x } # fastest path - end + @parser.chunked? ? each_rechunk { |x| yield x } : + each_identity { |x| yield x } end - rescue EOFError end # :stopdoc: def reset @parser.reset @@ -121,9 +114,10 @@ # easy, just read and write everything until EOFError dst = @sock.readpartial(READ_SIZE) begin yield dst end while @sock.readpartial(READ_SIZE, dst) + rescue EOFError end def each_identity len = @parser.body_bytes_left if len == nil