Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Output gets cut off #75

Closed
jrnbs opened this Issue · 6 comments

7 participants

@jrnbs

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

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.

@Jensen2k

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.

@widget102

I had the same problem with nginx. I deleted zlib.output_compression in "response" function and it helps.

@michaelbrooks

Is there any solution to this problem besides disabling ob_start('ob_gzhandler'); ?

@bubbafoley

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.

@bubbafoley

here is the fix

#103

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.