summaryrefslogtreecommitdiff
path: root/lib/chef/http
diff options
context:
space:
mode:
authorJohn Keiser <jkeiser@opscode.com>2014-09-04 21:38:07 -0700
committerJohn Keiser <jkeiser@opscode.com>2014-09-07 10:44:26 -0700
commit3fb87cc744d1e1134476496dedc9125a25add859 (patch)
tree3f31bf92ef0ed2a50fdff54e23c5611db6b60ce9 /lib/chef/http
parentc8b1e30a8b558c29a1ce1cc6a5a1e5de56534d22 (diff)
downloadchef-3fb87cc744d1e1134476496dedc9125a25add859.tar.gz
Print out request and response body on non-2xx responsejk/http-error-log
Diffstat (limited to 'lib/chef/http')
-rw-r--r--lib/chef/http/basic_client.rb14
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/chef/http/basic_client.rb b/lib/chef/http/basic_client.rb
index b9a82499ed..f0f5151dbd 100644
--- a/lib/chef/http/basic_client.rb
+++ b/lib/chef/http/basic_client.rb
@@ -71,6 +71,20 @@ class Chef
end
Chef::Log.debug("---- End HTTP Status/Header Data ----")
+ # For non-400's, log the request and response bodies
+ if !response.code || !response.code.start_with?('2')
+ if response.body
+ Chef::Log.debug("---- HTTP Response Body ----")
+ Chef::Log.debug(response.body)
+ Chef::Log.debug("---- End HTTP Response Body -----")
+ end
+ if req_body
+ Chef::Log.debug("---- HTTP Request Body ----")
+ Chef::Log.debug(req_body)
+ Chef::Log.debug("---- End HTTP Request Body ----")
+ end
+ end
+
yield response if block_given?
# http_client.request may not have the return signature we want, so
# force the issue: