Kohana 3.2 request-> headers ['Content-Type']一直失败

Ser*_*hiy 3 php content-type header kohana kohana-3

由于某些原因,这在Kohana 3.2中不起作用:

$this->request->headers['Content-Type'] = 'text/xml';
Run Code Online (Sandbox Code Playgroud)

自Kohana 3.1以来有没有改变?

Dar*_*tar 5

它也不应该在3.1中工作,但这应该:

$this->request->headers('Content-Type', 'text/xml');
Run Code Online (Sandbox Code Playgroud)

请参阅http://kohanaframework.org/3.2/guide/api/Request#headers 这是3.1中的请求/响应重构更改之一.

  • 我相信你需要在3.2中使用响应对象吗?$ this-> response-> headers('Content-Type','text/xml'); (3认同)