最后几个字符codeigniter REST API缺失,JSON响应 [英] Last few characters missing in Codeigniter REST API, json Response

查看:222
本文介绍了最后几个字符codeigniter REST API缺失,JSON响应的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用codeigniter REST API,和我有一个响应code这样的

  $这个 - >响应(阵列('错误'=>'项目找不到'),403);

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

  {错误:项目无法foun

在过去几个字符缺失

实际输出应该是这样的。

  {错误:项目找不到}


解决方案

我是有这REST_Controller同样的问题。这可能是一个黑客位,但是这为我工作。


  1. 开启REST_Controller.php

  2. 找到并删除下面的code(在响应函数的末尾):

     如果($这个 - >!_zlib_oc和放大器;&安培;!$ CFG->项目('COM press_output'))
    {
        标题(内容长度:strlen的($输出));
    }


然后,它开始呈现出完整的JSON响应。

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

the last few characters are missing

The actual output should be like this

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

解决方案

I was having the same problem with that REST_Controller. This could be a bit of a hack, but this worked for me.

  1. Open REST_Controller.php
  2. Locate and delete the following code (at the end of the response function):

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

Then it started showing the complete json response.

这篇关于最后几个字符codeigniter REST API缺失,JSON响应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆