# File lib/ftw/protocol.rb, line 164 def read_http_body_length(length, &block) remaining = length while remaining > 0 data = @body.read(remaining) @logger.debug("Read bytes", :length => data.bytesize) if data.bytesize > remaining # Read too much data, only wanted part of this. Push the rest back. yield data[0..remaining] remaining = 0 @body.pushback(data[remaining .. -1]) if remaining < 0 else yield data remaining -= data.bytesize end end end