Codeigniter REST API 中缺少最后几个字符,json 响应 [英] Last few characters missing in Codeigniter REST API, json Response
本文介绍了Codeigniter REST API 中缺少最后几个字符,json 响应的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用 Codeigniter REST API,并且我有这样的响应代码
I am using Codeigniter REST API, and i am having a response code like this
$this->response(array('error' => 'Items could not be found'),403);
它在本地机器上正常工作,但在服务器上我得到这样的输出
It works correctly in local machine, But on server i get an output like this
{"error":"Items could not be foun
缺少最后几个字符
实际输出应该是这样的
{"error":"Items could not be found"}
推荐答案
我在使用 REST_Controller 时遇到了同样的问题.这可能有点黑客,但这对我有用.
I was having the same problem with that REST_Controller. This could be a bit of a hack, but this worked for me.
- 打开 REST_Controller.php
找到并删除以下代码(在
response
函数的末尾):
if ( ! $this->_zlib_oc && ! $CFG->item('compress_output'))
{
header('Content-Length: ' . strlen($output));
}
然后它开始显示完整的 json 响应.
Then it started showing the complete json response.
这篇关于Codeigniter REST API 中缺少最后几个字符,json 响应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文