RestController的getAcceptType方法错误

浏览:1028 发布日期:2015/04/02
3.2.3 - 严重 - 未处理
[HTTP_ACCEPT] => text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
每个类型都有权重,在此例中应优先选中text/html或application/xhtml+xml

而getAcceptType方法中循环$type数组
$type = array(
'xml' => 'application/xml,text/xml,application/x-xml',
'json' => 'application/json,text/x-json,application/jsonrequest,text/json',
'js' => 'text/javascript,application/javascript,application/x-javascript',
'css' => 'text/css',
'rss' => 'application/rss+xml',
'yaml' => 'application/x-yaml,text/yaml',
'atom' => 'application/atom+xml',
'pdf' => 'application/pdf',
'text' => 'text/plain',
'png' => 'image/png',
'jpg' => 'image/jpg,image/jpeg,image/pjpeg',
'gif' => 'image/gif',
'csv' => 'text/csv',
'html' => 'text/html,application/xhtml+xml,*/*'
);
此数组xml是第一个元素,匹配到了http_accept中的application/xml;q=0.9,所以返回了资源类型就是xml
但其实本次访问只是一次浏览器的普通访问,资源类型本应是html
评论(
后面还有条评论,点击查看>>