最近我把我的rest server升级到了Zf2 Apigility,内容协商设置如下,
'zf-content-negotiation' => array(
'controllers' => array(
'CloudSchoolBusFileApi\\V1\\Rest\\FileReceiver\\Controller' => 'Json',
),
'accept_whitelist' => array(
'CloudSchoolBusFileApi\\V1\\Rest\\FileReceiver\\Controller' => array(
0 => 'application/vnd.cloud-school-bus-file-api.v1+json',
1 => 'application/json',
),
),
'content_type_whitelist' => array(
'CloudSchoolBusFileApi\\V1\\Rest\\FileReceiver\\Controller' => array(
0 => 'application/vnd.cloud-school-bus-file-api.v1+json',
1 => 'application/json',
2 => 'multipart/form-data',
),
),
问题是我的客户端(移动应用程序)已经部署,并且他们发送的 post 请求在 http 标头中没有 Accept 字段设置。所以我总是从服务器收到以下 406 错误,
[Response] => Array
(
[statusCode] => 406
[content] => {"type":"http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html","title":"Not Acceptable","status":406,"detail":"Cannot honor Accept type specified"}
)
因此,任何人都知道如何让服务器接受来自客户端的此类请求,而标头中没有 Accept?