diff options
author | Lamont Granquist <lamont@opscode.com> | 2013-03-27 14:29:07 -0700 |
---|---|---|
committer | Lamont Granquist <lamont@opscode.com> | 2013-03-27 14:29:07 -0700 |
commit | e8ba178af9dcbe8ae05eeb655f3427375dfdab19 (patch) | |
tree | fd566dc5fd98e643925237fbe35d8fb2eadb4aad /lib/chef/rest.rb | |
parent | 6c434dcec8403001eeb65792830a5e38229589f8 (diff) | |
parent | eca7dbdf852d75c176593b66d5dcaf0fe517a87a (diff) | |
download | chef-e8ba178af9dcbe8ae05eeb655f3427375dfdab19.tar.gz |
Merge branch 'master' into file-refactor
Diffstat (limited to 'lib/chef/rest.rb')
-rw-r--r-- | lib/chef/rest.rb | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/chef/rest.rb b/lib/chef/rest.rb index 8f5405f9d2..904c758779 100644 --- a/lib/chef/rest.rb +++ b/lib/chef/rest.rb @@ -190,7 +190,11 @@ class Chef 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))} + if [:GET, :HEAD].include?(method) + follow_redirect {api_request(method, create_url(redirect_location))} + else + raise Exceptions::InvalidRedirect, "#{method} request was redirected from #{url} to #{redirect_location}. Only GET and HEAD support redirects." + end else # have to decompress the body before making an exception for it. But the body could be nil. response.body.replace(response_body) if response.body.respond_to?(:replace) |