diff options
Diffstat (limited to 'lib/chef/http/json_input.rb')
-rw-r--r-- | lib/chef/http/json_input.rb | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/chef/http/json_input.rb b/lib/chef/http/json_input.rb index 23ccc3a8a7..3296d8821f 100644 --- a/lib/chef/http/json_input.rb +++ b/lib/chef/http/json_input.rb @@ -25,14 +25,19 @@ class Chef # Middleware that takes json input and turns it into raw text class JSONInput + attr_accessor :opts + def initialize(opts={}) + @opts = opts end def handle_request(method, url, headers={}, data=false) if data && should_encode_as_json?(headers) headers.delete_if { |key, _value| key.downcase == 'content-type' } headers["Content-Type"] = 'application/json' - data = Chef::JSONCompat.to_json(data) + json_opts = {} + json_opts[:validate_utf8] = opts[:validate_utf8] if opts.has_key?(:validate_utf8) + data = Chef::JSONCompat.to_json(data, json_opts) # Force encoding to binary to fix SSL related EOFErrors # cf. http://tickets.opscode.com/browse/CHEF-2363 # http://redmine.ruby-lang.org/issues/5233 |