diff options
author | danielsdeleo <dan@opscode.com> | 2012-10-22 16:41:07 -0700 |
---|---|---|
committer | danielsdeleo <dan@opscode.com> | 2012-10-31 17:07:55 -0700 |
commit | df9016e24efebad559fe368246e8af91a3306e1d (patch) | |
tree | 1b2bcdb99246ee31aff092ad2399e3e0a10df309 /lib/chef/rest.rb | |
parent | 630d9c4d4f25dd72c660a2cc024a0ac506308951 (diff) | |
download | chef-df9016e24efebad559fe368246e8af91a3306e1d.tar.gz |
[OC-3553] add 304 NotModified support to raw_http_request
304 support was previously in #run_request, which is deprecated and
going away. To support If-Modified-Since in the http_request resource,
we need to add support for 304 to the api we're keeping.
Diffstat (limited to 'lib/chef/rest.rb')
-rw-r--r-- | lib/chef/rest.rb | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/chef/rest.rb b/lib/chef/rest.rb index 43525082f2..ab9c3b20e3 100644 --- a/lib/chef/rest.rb +++ b/lib/chef/rest.rb @@ -280,8 +280,10 @@ class Chef Chef::JSONCompat.from_json(response_body.chomp) else Chef::Log.warn("Expected JSON response, but got content-type '#{response['content-type']}'") - response_body + response_body.to_s end + elsif response.kind_of?(Net::HTTPNotModified) # Must be tested before Net::HTTPRedirection because it's subclass. + false elsif redirect_location = redirected_to(response) follow_redirect {api_request(:GET, create_url(redirect_location))} else @@ -306,7 +308,7 @@ class Chef end def decompress_body(response) - if gzip_disabled? + if gzip_disabled? || response.body.nil? response.body else case response[CONTENT_ENCODING] |