I'm currently using REST_controller V 2.5.x and found this problem:
When the content-length gets longer then 8000 bytes (the content-length set as http header by the library) the whole JSON output always misses the last two characters, making it invalid and unusable. After some debugging I found out the whole problem went away when I removed the line where the 'content-length' header is being set in the response() function. Apparently setting the http header causes the whole JSON output to be two characters shorter than it's supposed to, only in JSON btw..
I believe the issue is down to the use of the exit function, exit() and die() both flush the output buffer. Are you using output buffering in your app? If so this might be the cause of your issue. You could try appending the content of the output buffer (without flushing it) to the strlen method, however I can't guarantee that will fix it.
I had the same problem, but did not use output buffering anywhere in my own code.
I solved it by adding ob_clean(); right before the headers in the return-method of REST_Controller.php.
I had the same problem with nginx. I deleted zlib.output_compression in "response" function and it helps.
Is there any solution to this problem besides disabling ob_start('ob_gzhandler'); ?
if output_compression is enabled then the content-length header is wrong because it's sending the length of the uncompressed content. the (speedy) solution is to not send the content-length header when the output is compressed (that's how CI_Output does it.)
i'll try and do a pull request tonight if I have time.
here is the fix