diff options
author | Shane da Silva <shane@dasilva.io> | 2016-10-15 12:05:33 -0700 |
---|---|---|
committer | Shane da Silva <shane@dasilva.io> | 2016-10-15 12:07:00 -0700 |
commit | f3e8c95def2f34f15fcb114284f86060a7fa73d5 (patch) | |
tree | 8c1769d68493b42263a00f93abf32d4f028e990e | |
parent | 19033178804d7932ba0e25c029b7bdff49e1d545 (diff) | |
download | chef-f3e8c95def2f34f15fcb114284f86060a7fa73d5.tar.gz |
Rebuild HTTP headers on each retried request
Depending on how you configure your Chef client, it's possible that a
later retry would have an authentication timestamp header
(`X-OPS-TIMESTAMP`) that was more than 900 seconds old. Since the Chef
server treats timestamps older than this threshold as unauthorized
requests, you would potentially get seemingly spurious "401
Unauthorized" responses from the server.
A solution is to generate the headers on each retry so that we have a
new authentication timestamp for each retried request.
Signed-off-by: Shane da Silva <shane@dasilva.io>
-rw-r--r-- | lib/chef/http.rb | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/lib/chef/http.rb b/lib/chef/http.rb index 924081bc6b..dd3c55bf19 100644 --- a/lib/chef/http.rb +++ b/lib/chef/http.rb @@ -329,10 +329,9 @@ class Chef # Runs a synchronous HTTP request, with no middleware applied (use #request # to have the middleware applied). The entire response will be loaded into memory. # @api private - def send_http_request(method, url, headers, body, &response_handler) - headers = build_headers(method, url, headers, body) - + def send_http_request(method, url, base_headers, body, &response_handler) retrying_http_errors(url) do + headers = build_headers(method, url, base_headers, body) client = http_client(url) return_value = nil if block_given? |