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 RestClient.log
if size == 0
RestClient.log << "#{@method} #{@url} done (0 length file\n)"
elsif total == 0
RestClient.log << "#{@method} #{@url} (zero content length)\n"
else
RestClient.log << "#{@method} #{@url} %d%% done (%d of %d)\n" % [(size * 100) / total, size, total]
end
end
end
@tf.close
@tf
else
http_response.read_body
end
http_response
end