def fetch_body(http_response)
if @raw_response
@tf = Tempfile.new("rest-client")
size, total = 0, http_response.header['Content-Length'].to_i
http_response.read_body do |chunk|
@tf.write(chunk)
size += chunk.size
if size == 0
display_log("#{@method} #{@url} done (0 length file)")
elsif total == 0
display_log("#{@method} #{@url} (zero content length)")
else
display_log("#{@method} #{@url} %d%% done (%d of %d)" % [(size * 100) / total, size, total])
end
end
@tf.close
@tf
else
http_response.read_body
end
http_response
end