diff options
author | Steven Danna <steve@opscode.com> | 2013-04-30 22:05:30 -0700 |
---|---|---|
committer | Steven Danna <steve@opscode.com> | 2013-04-30 22:09:04 -0700 |
commit | 561413f890d60879e7482f4961c32638d80ede75 (patch) | |
tree | 1767f2192174e795d6c7169fd302b08fec2853b1 /lib/chef_zero/rest_base.rb | |
parent | 27b2bbe028488d46a2444dcd8a3e35d4a9d1f0e5 (diff) | |
download | chef-zero-561413f890d60879e7482f4961c32638d80ede75.tar.gz |
Assume application/json is acceptable if no Accept header was sent.
This is the behavior of the full Chef Server and complies with the
RFC.
Closes #3
Diffstat (limited to 'lib/chef_zero/rest_base.rb')
-rw-r--r-- | lib/chef_zero/rest_base.rb | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/chef_zero/rest_base.rb b/lib/chef_zero/rest_base.rb index a525be7..f22f4a3 100644 --- a/lib/chef_zero/rest_base.rb +++ b/lib/chef_zero/rest_base.rb @@ -21,7 +21,7 @@ module ChefZero accept_methods_str = accept_methods.map { |m| m.to_s.upcase }.join(', ') return [405, {"Content-Type" => "text/plain", "Allow" => accept_methods_str}, "Bad request method for '#{request.env['REQUEST_PATH']}': #{request.env['REQUEST_METHOD']}"] end - if json_only && !request.env['HTTP_ACCEPT'].split(';').include?('application/json') + if json_only && request.env['HTTP_ACCEPT'] && !request.env['HTTP_ACCEPT'].split(';').include?('application/json') return [406, {"Content-Type" => "text/plain"}, "Must accept application/json"] end # Dispatch to get()/post()/put()/delete() |