Skip to content

Commit

Permalink
Make sure that content-length header can never be deleted
Browse files Browse the repository at this point in the history
Once the response is `commit`ted, the headers can't be edited anymore, which is
exactly what we want in this case.
  • Loading branch information
chvp committed Nov 8, 2023
1 parent 01f4655 commit b997a39
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions app/controllers/tracks_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down

0 comments on commit b997a39

Please sign in to comment.