Output gets cut off #75

Closed
jrnbs opened this Issue Dec 12, 2011 · 6 comments

Comments

Projects
None yet
7 participants

jrnbs commented Dec 12, 2011

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..

15watts commented Jan 4, 2012

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'); ?

Contributor

ruthlessfish commented Mar 9, 2012

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.)

https://bugs.php.net/bug.php?id=44164

i'll try and do a pull request tonight if I have time.

Contributor

ruthlessfish commented Mar 14, 2012

here is the fix

philsturgeon#103

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment