mirror of
https://github.com/floci-io/floci.git
synced 2026-11-27 07:39:24 -05:00
fix(cloudfront): release origin connections when viewers disconnect (#5564)
This commit is contained in:
1 parent
66b2ec05e9
commit
ee229af975
2 files changed
+65
No files matched your search
+4
@@ -34,6 +34,7 @@ import jakarta.ws.rs.core.Response;
|
||||
import jakarta.ws.rs.core.StreamingOutput;
|
||||
import jakarta.ws.rs.core.UriInfo;
|
||||
import org.jboss.logging.Logger;
|
||||
import org.jboss.resteasy.reactive.server.core.CurrentRequestManager;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
@@ -1022,6 +1023,9 @@ public class CloudFrontServingController {
|
||||
}
|
||||
}
|
||||
if (includeBody && origin.stream() != null) {
|
||||
// A disconnected viewer can skip StreamingOutput entirely, so its finally block
|
||||
// alone cannot release the origin connection.
|
||||
CurrentRequestManager.get().registerCompletionCallback(ignored -> origin.closeStream());
|
||||
InputStream body = origin.stream();
|
||||
StreamingOutput entity = output -> {
|
||||
try (InputStream in = body) {
|
||||
|
||||
Reference in new issue
Block a user