Skip to content

Commit 1a40d16

Browse files
committed
fix(transcode): ignore Content-Length from non-2xx HEAD responses
resolve_file_size() trusted Content-Length unconditionally, so a 405 (or any 4xx/5xx) HEAD response with a short error body (e.g. 18-byte "Method Not Allowed") set _file_size to that tiny value. The probe stage then clamped header_size to 18 bytes, logged "Header too small", and the transcode pipeline returned 404. Only read Content-Length from HEAD when status < 400; otherwise fall through to the existing Range: bytes=0-0 GET branch which reads the real size from Content-Range. Fixes: upstreams like AIOStreams /api/v1/debrid/playback/ that 405 on HEAD. Closes #276
1 parent 320015c commit 1a40d16

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

mediaflow_proxy/remuxer/media_source.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ async def resolve_file_size(self) -> int:
198198
proxy=proxy_url,
199199
allow_redirects=True,
200200
) as resp:
201-
cl = resp.headers.get("content-length")
201+
cl = resp.headers.get("content-length") if resp.status < 400 else None
202202
if cl:
203203
self._file_size = int(cl)
204204
else:

0 commit comments

Comments
 (0)