【问题标题】:Zend Framework setHttpResponseCode is not modifying the response headerZend Framework setHttpResponseCode 没有修改响应头
【发布时间】:2017-12-28 22:07:37
【问题描述】:

我正在使用zend框架ErrorController,但是由于某种原因,当应用程序发生错误时,setHttpResponseCode应该将它设置为500,但是当我

echo get_headers("my_url")

,我还在继续

数组([0] => HTTP/1.1 200)

知道如何将标头修改为标头('HTTP/1.1 403 Forbidden'); 当我在 get_headers() 之前写下这一行时发生的事件,我仍然得到相同的 200 个标题。

【问题讨论】:

    标签: zend-framework header


    【解决方案1】:

    我认为您需要在 settHttpResponseCode() 之后调用 sendHeaders()。

    这是来自 ZF 中的 doc 块:

    /**
     * Send all headers
     *
     * Sends any headers specified. If an {@link setHttpResponseCode() HTTP response code}
     * has been specified, it is sent with the first header.
     *
     * @return Zend_Controller_Response_Abstract
     */
    public function sendHeaders()
    

    【讨论】:

    • 感谢您的快速回答,但我发现了错误,我正在我的项目中实现 ACL,所以实际上显示的这些标题是用于登录页面,而不是实际请求的 url。
    猜你喜欢
    • 1970-01-01
    • 2016-08-04
    • 1970-01-01
    • 1970-01-01
    • 2020-10-14
    • 2017-06-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多