Thanks Greg, I was able to get it working with the following code:

@Override
protected void onResponseContent(HttpServletRequest request, 
HttpServletResponse response, Response proxyResponse, byte[] buffer, int 
offset, int length, Callback callback) {

super.onResponseContent(request, response, proxyResponse, buffer, offset, 
length, new Callback.Nested(callback) {
@Override
public void completed() {
if("text/event-stream".equalsIgnoreCase(response.getContentType())) {
try {
response.flushBuffer();
((org.eclipse.jetty.server.Response)response).getHttpOutput().isReady();
}
catch(Exception e) {
throw new RuntimeException(e);
}
}
}
});}

The call to isReady() seems to be necessary with AsyncProxyServlet, but not 
with ProxyServlet.
------- Original Message -------
On Monday, July 11th, 2022 at 10:13 PM, Greg Wilkins <gr...@webtide.com> wrote:

> You are able to call response.flushBuffers() to flush any buffered content.
>
> On Tue, 12 July 2022, 14:25 LP via jetty-users, <jetty-users@eclipse.org> 
> wrote:
>
>> Hi,
>>
>> My understanding of HTTP/1.1 chunking is that it's considered to be a 
>> hop-to-hop feature, and so if the server behind an (Async)ProxyServlet 
>> responds with a stream of small chunks they can be buffered. This poses a 
>> challenge for some chunking use-cases, including SSE (Server Sent Events). 
>> One workaround I found for SSE is to send a large-ish "flush" event with 
>> some random junk after each "real" event to push the real event through the 
>> buffer. This works fine when the events aren't too frequent, but it's 
>> obviously not a great solution.
>>
>> Is there any functionality available that allows for setting a timeout in 
>> the ProxyServlet after which any buffered response content would 
>> automatically be flushed via chunking? If not, would this be difficult to 
>> implement?
>>
>> Jetty rules!
>>
>> Thanks,
>> LP
>> _______________________________________________
>> jetty-users mailing list
>> jetty-users@eclipse.org
>> To unsubscribe from this list, visit 
>> https://www.eclipse.org/mailman/listinfo/jetty-users
_______________________________________________
jetty-users mailing list
jetty-users@eclipse.org
To unsubscribe from this list, visit 
https://www.eclipse.org/mailman/listinfo/jetty-users

Reply via email to