Servlet buffering response despite calls to flush()

前端 未结 6 569
盖世英雄少女心
盖世英雄少女心 2021-02-08 04:10

We have a system where a client makes an HTTP GET request, the system does some processing on the backend, zips the results, and sends it to the client. Since the processing can

6条回答
  •  暗喜
    暗喜 (楼主)
    2021-02-08 04:25

    The issue is that by default each servlet implementation buffers the data whereas SSE and other custom requirements might/will need data immediately.

    The solution is to do the following:

    response.setBufferSize(1) // or some similar small number for such servlets. 
    

    This will ensure that the data is written out earlier (with the resultant performance loss)

提交回复
热议问题