diff options
author | Tim Smith <tsmith@chef.io> | 2020-07-27 17:02:23 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-07-27 17:02:23 -0700 |
commit | 1f392d82aacbd604a3eb2cd151d52583ea1d8a27 (patch) | |
tree | d31f809d39c1c22ed13641818fd0c9a277c8ed03 | |
parent | 37c018a6d44a999ed17e21c2f0e3b3c0cf2030fe (diff) | |
parent | 09cdc96cb25956b3ef053fbe093d06453a7af92b (diff) | |
download | chef-1f392d82aacbd604a3eb2cd151d52583ea1d8a27.tar.gz |
Merge pull request #10216 from chef/fix-406-no-method-error
Fix NoMethodError when server returns a 406.
-rw-r--r-- | lib/chef/http.rb | 7 | ||||
-rw-r--r-- | spec/unit/server_api_spec.rb | 6 |
2 files changed, 11 insertions, 2 deletions
diff --git a/lib/chef/http.rb b/lib/chef/http.rb index 1777739a93..eed2a41815 100644 --- a/lib/chef/http.rb +++ b/lib/chef/http.rb @@ -58,7 +58,6 @@ class Chef handler.handle_chunk(chunk) end end - end def self.middlewares @@ -471,7 +470,11 @@ class Chef end def version_retries - @version_retries ||= options[:version_class].possible_requests + @version_retries ||= if options[:version_class] + options[:version_class].possible_requests + else + 0 + end end # @api private diff --git a/spec/unit/server_api_spec.rb b/spec/unit/server_api_spec.rb index bda6003487..1b5d729383 100644 --- a/spec/unit/server_api_spec.rb +++ b/spec/unit/server_api_spec.rb @@ -123,4 +123,10 @@ describe Chef::ServerAPI do client.get("foo") end end + + it "does not retry a 406 Not Acceptable" do + WebMock.disable_net_connect! + stub_request(:get, "http://chef.example.com:4000/foo").to_return(status: [406, "Not Acceptable"]) + expect { client.get("foo") }.to raise_error(Net::HTTPServerException) + end end |