server sometimes returns chunked transfer encoding

前端 未结 3 1224
旧时难觅i
旧时难觅i 2020-12-20 03:23

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

3条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-20 03:54

    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

提交回复
热议问题