Skip to content

Commit

Permalink
Fix responses not being streamed (#347)
Browse files Browse the repository at this point in the history
The ETag calculation was still happening, so somewhat slow
responses (e.g. transcodes of an hour of music) could take a minute until first
byte sent. This means that clients time out when trying to stream these files.
  • Loading branch information
chvp authored Jun 20, 2022
1 parent 4dc22d2 commit 060652a
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions app/controllers/tracks_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@ 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
# Workaround for https://github.com/rack/rack/issues/1619
# Remove when rack 3.0 is released
response.headers['last-modified'] = Time.now.httpdate

to_skip = first_byte
while to_skip.positive?
Expand Down

0 comments on commit 060652a

Please sign in to comment.