diff --git a/src/main/java/com/dostalgia/StaticResource.java b/src/main/java/com/dostalgia/StaticResource.java index 2f5d4fa..2a9bbf2 100644 --- a/src/main/java/com/dostalgia/StaticResource.java +++ b/src/main/java/com/dostalgia/StaticResource.java @@ -80,12 +80,11 @@ public class StaticResource { return Response.serverError().build(); } - // No Range header — serve the full file (200 OK) + // No Range header — serve the full file (200 OK, chunked encoding) if (rangeHeader == null || rangeHeader.isBlank()) { Response.ResponseBuilder rb = Response.ok(new FileStream(file, 0, fileSize)) .type(contentType) - .header("Accept-Ranges", "bytes") - .header("Content-Length", fileSize); + .header("Accept-Ranges", "bytes"); if (cacheControl != null) { rb.header("Cache-Control", cacheControl); } @@ -131,12 +130,11 @@ public class StaticResource { return rb.build(); } - /** Convenience: full-file 200 response. */ + /** Convenience: full-file 200 response (chunked encoding, no Content-Length). */ private Response serveFull(Path file, String contentType, long fileSize, String cacheControl) { Response.ResponseBuilder rb = Response.ok(new FileStream(file, 0, fileSize)) .type(contentType) - .header("Accept-Ranges", "bytes") - .header("Content-Length", fileSize); + .header("Accept-Ranges", "bytes"); if (cacheControl != null) { rb.header("Cache-Control", cacheControl); }