jetty.project icon indicating copy to clipboard operation
jetty.project copied to clipboard

AsyncMiddleManServlet response flushing

Open iiliev2 opened this issue 1 year ago • 10 comments
trafficstars

Jetty 12 ee8

Java 21

Continuing the discussion from https://github.com/jetty/jetty.project/issues/12294#issuecomment-2374287136 as this is a separate topic.

The proxy servlets(in particular AsyncMiddleManServlet, as that is what I am looking at) do not seem to flush responses as the proxy client receives new bytes. Ideally it should auto flush in an optimal way(for ex. if http1.1 and chunked, it should flush on each full chunk). Otherwise there could be huge delays between when the data is available and when it is actually returned to the caller(due to buffering). Since this is a proxy, I expected this to be the default, otherwise I hope to be able to set it up that way.

The ContentTransformer does not seem to provide a way to control this(suggested in the previous github question). That abstraction is about mutating the raw data in some way.

The only way that I can see from the code of AsyncMiddleManServlet is to call flush on the ServletOutputStream right after ProxyWriter calls writeProxyResponseContent. Unfortunatly that method is package private so the only way is to override the entire onWritePossible and flush afterward.

What would you advise is the right way to do this?

iiliev2 avatar Sep 27 '24 08:09 iiliev2