Tomcat does not flush the response buffer

后端 未结 4 1701
[愿得一人]
[愿得一人] 2020-12-11 05:10

i tested HttpResponse#flushBuffer and PrintWriter#flush on Tomcat 7 below, but it seemed that the response rather ignored them than fl

4条回答
  •  盖世英雄少女心
    2020-12-11 05:24

    I had that issue, too. And I found, too, that the issue goes away with curl. With some sniffing, it turned out that the culprit is gzip encoding. In order to compress the response, gzip waits until the underlying PrintWriter is closed (that is, until the full response is written) and then produces the compressed output. On the client side, this means that you do not get anything back until the full response is ready. Curl, on the other hand, does not issue an Accept-Encoding: gzip to the server, and that's why the thing works, and you can get the chunked output normally as intended.

提交回复
热议问题