summaryrefslogtreecommitdiff
path: root/lib/chef_zero/rest_base.rb
diff options
context:
space:
mode:
authorSteven Danna <steve@opscode.com>2013-04-30 22:05:30 -0700
committerSteven Danna <steve@opscode.com>2013-04-30 22:09:04 -0700
commit561413f890d60879e7482f4961c32638d80ede75 (patch)
tree1767f2192174e795d6c7169fd302b08fec2853b1 /lib/chef_zero/rest_base.rb
parent27b2bbe028488d46a2444dcd8a3e35d4a9d1f0e5 (diff)
downloadchef-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.rb2
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()