From 561413f890d60879e7482f4961c32638d80ede75 Mon Sep 17 00:00:00 2001 From: Steven Danna Date: Tue, 30 Apr 2013 22:05:30 -0700 Subject: [PATCH] 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 --- lib/chef_zero/rest_base.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/chef_zero/rest_base.rb b/lib/chef_zero/rest_base.rb index a525be7b..f22f4a3e 100644 --- a/lib/chef_zero/rest_base.rb +++ b/lib/chef_zero/rest_base.rb @@ -21,7 +21,7 @@ def call(request) 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()