summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlamont-granquist <lamont@scriptkiddie.org>2014-08-26 16:43:04 -0700
committerlamont-granquist <lamont@scriptkiddie.org>2014-08-26 16:43:04 -0700
commit847365e6198056a82fbad48d835e8fed92282e14 (patch)
tree80ab551eb51496314d3803cabbd0da0fdfd9d1e8
parentde8e2612785c1f9f4bdd05787dcc47d55ef348c6 (diff)
parent5703407d41822d5a6efb9df18cab56e0e2e4f390 (diff)
downloadchef-847365e6198056a82fbad48d835e8fed92282e14.tar.gz
Merge pull request #1896 from opscode/lcg/1869
response.body may be nil
-rw-r--r--lib/chef/http/json_output.rb9
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/chef/http/json_output.rb b/lib/chef/http/json_output.rb
index 7a3b9c8638..069eb6a87f 100644
--- a/lib/chef/http/json_output.rb
+++ b/lib/chef/http/json_output.rb
@@ -26,6 +26,9 @@ class Chef
# Middleware that takes an HTTP response, parses it as JSON if possible.
class JSONOutput
+ attr_accessor :raw_output
+ attr_accessor :inflate_json_class
+
def initialize(opts={})
@raw_output = opts[:raw_output]
@inflate_json_class = opts[:inflate_json_class]
@@ -44,10 +47,12 @@ class Chef
# needed to keep conditional get stuff working correctly.
return [http_response, rest_request, return_value] if return_value == false
if http_response['content-type'] =~ /json/
- if @raw_output
+ if http_response.body.nil?
+ return_value = nil
+ elsif raw_output
return_value = http_response.body.to_s
else
- if @inflate_json_class
+ if inflate_json_class
return_value = Chef::JSONCompat.from_json(http_response.body.chomp)
else
return_value = Chef::JSONCompat.parse(http_response.body.chomp)