Skip to content

Fix local file server: MIME types, reliable Range seeks, registry bound - #5

Merged
yinnho merged 1 commit into
masterfrom
fix/local-file-server
Sep 2, 2026
Merged

Fix local file server: MIME types, reliable Range seeks, registry bound#5
yinnho merged 1 commit into
masterfrom
fix/local-file-server

Conversation

@yinnho

@yinnho yinnho commented Sep 2, 2026

Copy link
Copy Markdown
Owner

Summary

  • Serve real MIME types by file extension (mp4/mkv/avi/mov/ts/mp3/flac/...) instead of always application/octet-stream — some TVs refuse unknown content types
  • Loop InputStream.skip() until the requested Range offset is fully skipped: a single skip() call may skip fewer bytes than requested, which started the HTTP body at the wrong offset and produced a corrupt stream after a seek
  • Bound the token registry with an LRU cap of 64 entries — each cast mints a new token and the previous unbounded map leaked one entry per cast for the whole process lifetime

Test plan

  • ./gradlew test lint assembleRelease green locally
  • Manual: cast a local mkv/mp4 and seek — needs a real TV

- Serve correct MIME types by file extension instead of always
  application/octet-stream (some TVs reject or mis-handle unknown types)
- Loop InputStream.skip until the requested Range offset is reached;
  skip() may under-skip, which started the stream at the wrong position
  and corrupted seeked playback
- Bound the token registry (LRU, 64 entries): every cast mints a new
  token and the unbounded map leaked entries for the process lifetime

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@yinnho
yinnho merged commit b9b0df2 into master Sep 2, 2026
2 checks passed
@yinnho
yinnho deleted the fix/local-file-server branch September 2, 2026 09:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant