From e6484445fb873b2ccc5448cd4e6fc2b00ecbaf5b Mon Sep 17 00:00:00 2001 From: Lamont Granquist Date: Thu, 2 Mar 2017 17:05:13 -0800 Subject: protect against nil response body Signed-off-by: Lamont Granquist --- lib/chef/http/json_output.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/chef/http/json_output.rb b/lib/chef/http/json_output.rb index 179f1de4ef..dc363cdc54 100644 --- a/lib/chef/http/json_output.rb +++ b/lib/chef/http/json_output.rb @@ -61,7 +61,9 @@ class Chef [http_response, rest_request, return_value] else Chef::Log.debug("Expected JSON response, but got content-type '#{http_response['content-type']}'") - Chef::Log.debug("Response body contains:\n#{http_response.body.length < 256 ? http_response.body : http_response.body[0..256] + " [...truncated...]"}") + if http_response.body + Chef::Log.debug("Response body contains:\n#{http_response.body.length < 256 ? http_response.body : http_response.body[0..256] + " [...truncated...]"}") + end return [http_response, rest_request, http_response.body.to_s] end end -- cgit v1.2.1