summaryrefslogtreecommitdiff
path: root/lib/chef/rest.rb
diff options
context:
space:
mode:
authordanielsdeleo <dan@opscode.com>2013-10-03 17:49:12 -0700
committerdanielsdeleo <dan@opscode.com>2013-10-08 15:01:47 -0700
commit4ab3df25941ab29f58109e2495d329b3d15dbc99 (patch)
tree1b2813332049281385e94270f05024d8df128888 /lib/chef/rest.rb
parent2f82c5b421d2a99cd0c098b4a2d5047d19cdc531 (diff)
downloadchef-4ab3df25941ab29f58109e2495d329b3d15dbc99.tar.gz
Add authentication and GZIP headers back to streaming requests
Diffstat (limited to 'lib/chef/rest.rb')
-rw-r--r--lib/chef/rest.rb20
1 files changed, 13 insertions, 7 deletions
diff --git a/lib/chef/rest.rb b/lib/chef/rest.rb
index 7ba0164403..cc57838df9 100644
--- a/lib/chef/rest.rb
+++ b/lib/chef/rest.rb
@@ -82,10 +82,6 @@ class Chef
authenticator.sign_requests?
end
- def last_response
- @last_response
- end
-
# Send an HTTP GET request to the path
#
# Using this method to +fetch+ a file is considered deprecated.
@@ -218,8 +214,11 @@ class Chef
# If no block is given, the tempfile is returned, which means it's up to
# you to unlink the tempfile when you're done with it.
def streaming_request(url, headers, &block)
- headers = build_headers(:GET, url, headers, nil, true)
- retriable_rest_request(:GET, url, nil, headers) do |rest_request|
+ method, url, headers, data = [@decompressor, @authenticator].inject([:GET, url, headers, nil]) do |req_data, middleware|
+ middleware.handle_request(*req_data)
+ end
+ headers = build_headers(method, url, headers, data)
+ retriable_rest_request(method, url, data, headers) do |rest_request|
begin
tempfile = nil
response = rest_request.call do |r|
@@ -330,7 +329,7 @@ class Chef
response['location']
end
- def build_headers(method, url, headers={}, json_body=false, raw=false)
+ def build_headers(method, url, headers={}, json_body=false)
headers = @default_headers.merge(headers)
headers['Content-Length'] = json_body.bytesize.to_s if json_body
headers.merge!(Chef::Config[:custom_http_headers]) if Chef::Config[:custom_http_headers]
@@ -364,6 +363,13 @@ class Chef
# DEPRECATED
############################################################################
+ # This is only kept around to provide access to cache control data in
+ # lib/chef/provider/remote_file/http.rb
+ # Find a better API.
+ def last_response
+ @last_response
+ end
+
def decompress_body(body)
@decompressor.decompress_body(body)
end