From b997a39adab5ecd84a47ab61a85e08eb45214faa Mon Sep 17 00:00:00 2001 From: Charlotte Van Petegem Date: Wed, 8 Nov 2023 22:36:32 +0100 Subject: [PATCH] Make sure that content-length header can never be deleted Once the response is `commit`ted, the headers can't be edited anymore, which is exactly what we want in this case. --- app/controllers/tracks_controller.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/controllers/tracks_controller.rb b/app/controllers/tracks_controller.rb index a54184b3..b675bff4 100644 --- a/app/controllers/tracks_controller.rb +++ b/app/controllers/tracks_controller.rb @@ -116,6 +116,7 @@ def audio_with_stream(stream, mimetype, total_size) response.content_type = mimetype response.headers['accept-ranges'] = 'bytes' response.headers['content-length'] = (last_byte - first_byte + 1).to_s + response.commit! to_skip = first_byte while to_skip.positive?