I\'m building a REST API.. Sometimes the server returns the response with chunked transfer encoding? Why is that?!
Why can\'t the server always return the response in
Assuming your server is using Apache, this is expected behaviour. You can disable it by putting this line in your .htaccess
file:
SetEnv downgrade-1.0
However, you should consider modifying your reading code to just support different content encodings. What library are you using to make the HTTP request? Any reasonable HTTP library can handle chunked requests. If your requesting code is written in PHP, use curl. http://php.net/manual/en/book.curl.php
Taken from Server Fault:
A problem may be that Apache is gzipping your download, taking care of correcting the Content-Length, or in your case, adding the header
Content-Encoding: chunked
You can add a .htaccess
RewriteRule to disable gzip:
RewriteRule . - [E=no-gzip:1]