3

我正在使用 Codeigniter REST API,并且我有这样的响应代码

$this->response(array('error' => 'Items could not be found'),403);

它在本地机器上正常工作,但在服务器上我得到这样的输出

{"error":"Items could not be foun

最后几个字符丢失

实际输出应该是这样的

{"error":"Items could not be found"}
4

1 回答 1

8

我对那个 REST_Controller 有同样的问题。这可能有点麻烦,但这对我有用。

  1. 打开 REST_Controller.php
  2. 找到并删除以下代码(在response函数末尾):

    if ( ! $this->_zlib_oc && ! $CFG->item('compress_output'))
    {
        header('Content-Length: ' . strlen($output));
    }
    

然后它开始显示完整的 json 响应。

于 2014-01-14T22:38:19.120 回答