Hi,
This is the way TCP is designed: you cannot know if the peer closed the connection unless you read from or write to the socket, and HTTP/1.1 doesn't do anything to circumvent this.
If you know all the response headers before you create your big PDF, XLS, or CSV file, you could try responding with HTTP status 102 regularly until you finally respond with status 200, assuming all your clients do support this.
An alternative is to stream the response: write it bits by bits along your very long processing.
If you can change your API/website, a common workaround to this problem is to make one request to start the generation, then wait for an event (websocket or HTTP long polling) or regularly poll with HTTP GET requests figure out when the generation is done before attempting to download the generated resource with one final request.
Assuming you cannot do any of the above, you're unfortunately left only with Jetty's idle timeout to abort the request not knowing if the peer is still connected or not, or wait until all the data has been generated before attempting to write it and eventually detect that the peer is gone.
--
Ludovic