提交 61950a4b 编写于 作者: N Neeraj Singh 提交者: José Valim

current code ignores http header "Accept" if it

has ....,*/* .

It is possible to a device to send
request such that */* appear at the beginning of the
"Accept" header. This patch ensures that "Accept" header
is ignored for such cases too.
Signed-off-by: NJosé Valim <jose.valim@gmail.com>
上级 c937ddb5
......@@ -48,7 +48,7 @@ def formats
@env["action_dispatch.request.formats"] ||=
if parameters[:format]
Array(Mime[parameters[:format]])
elsif xhr? || (accept && accept !~ /,\s*\*\/\*/)
elsif xhr? || (accept && accept !~ /,\s*\*\/\*|\*\/\*,/)
accepts
else
[Mime::HTML]
......
......@@ -216,6 +216,12 @@ def test_js_or_html
assert_response 406
end
def test_json_or_yaml_with_leading_star_star
@request.accept = "*/*, application/json"
get :json_xml_or_html
assert_equal 'HTML', @response.body
end
def test_json_or_yaml
xhr :get, :json_or_yaml
assert_equal 'JSON', @response.body
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册