我在将Kohana 3中的Content-Type更改为XML时遇到了一些问题

时间:2012-02-20 22:40:08

标签: kohana content-type kohana-3

这是我的代码:

class Controller_Call extends Controller {

    public $template = 'tpl/default';

    public function before() {

            parent::before();

            $this->request->headers('Content-Type', 'text/xml');

            $this->template = View::factory($this->template);

    }

    public function action_index() {

            $this->template->response = '<say>Hey! How are you budy!</say>';

    }

    public function after() {

            $this->request->headers('Content-Type', 'text/xml');

            $this->response->body( $this->template );

            parent::after();

            $this->request->headers('Content-Type', 'text/xml');

    }

}

当我在firefox中加载页面并查看Content-Type时,我得到text / html。

为什么?

非常感谢您提前

1 个答案:

答案 0 :(得分:3)

您需要在响应中设置标题:

$this->response->headers('Content-Type', 'text/xml');