175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
|
# File 'lib/chef/http.rb', line 175
def streaming_request_with_progress(path, = {}, tempfile = nil, &progress_block)
http_attempts ||= 0
url = create_url(path)
response, rest_request, return_value = nil, nil, nil
data = nil
method = :GET
method, url, , data = apply_request_middleware(method, url, , data)
response, rest_request, return_value = send_http_request(method, url, , data) do |http_response|
if http_response.is_a?(Net::HTTPSuccess)
tempfile = stream_to_tempfile(url, http_response, tempfile, &progress_block)
end
apply_stream_complete_middleware(http_response, rest_request, return_value)
end
return nil if response.is_a?(Net::HTTPRedirection)
unless response.is_a?(Net::HTTPSuccess)
response.error!
end
tempfile
rescue Net::HTTPClientException => e
http_attempts += 1
response = e.response
if response.is_a?(Net::HTTPNotAcceptable) && version_retries - http_attempts >= 0
Chef::Log.trace("Negotiating protocol version with #{url}, retry #{http_attempts}/#{version_retries}")
retry
else
raise
end
rescue Exception => e
log_failed_request(response, return_value) unless response.nil?
raise
end
|