Created
October 10, 2008 20:25
-
-
Save hjkp/16150 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
res = nil | |
tf = nil | |
http.request(req) do |response| | |
if raw | |
tf = Tempfile.new("chef-rest") | |
# Stolen from http://www.ruby-forum.com/topic/166423 | |
# Kudos to _why! | |
size, total = 0, response.header['Content-Length'].to_i | |
response.read_body do |chunk| | |
tf.write(chunk) | |
size += chunk.size | |
Chef::Log.debug("#{req.path} %d%% done (%d of %d)" % [(size * 100) / total, size, total]) | |
end | |
tf.close | |
tf | |
else | |
response.read_body | |
end | |
res = response | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment