From 84a4606ae3fb278126c33d855d421d5a64d24654 Mon Sep 17 00:00:00 2001 From: David Young Date: Thu, 13 Aug 2026 18:18:48 +1200 Subject: [PATCH] fix: accept HEAD requests on the playback endpoint FastAPI's APIRoute does not add HEAD to a route's methods the way Starlette's Route does, so the playback endpoint answered 405 Method Not Allowed to any HEAD probe. Some clients (reported on Stremio for Android TV / ExoPlayer) probe a stream URL with HEAD before opening it. Register the route with api_route(methods=["GET", "HEAD"]). No handler changes are needed: request.method is already forwarded to custom_handle_stream_request, mediaflow_proxy's handle_stream_request has an explicit HEAD branch that closes the streamer and returns headers only, and combined_background_tasks already tolerates the resulting None close task. Starlette's FileResponse and RedirectResponse both handle HEAD by sending headers without a body. Verified against v2.58.0: HEAD now returns 200 with a zero-byte body and the same content-type GET serves. --- comet/api/endpoints/playback.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/comet/api/endpoints/playback.py b/comet/api/endpoints/playback.py index 35b1121f..3ae4e136 100644 --- a/comet/api/endpoints/playback.py +++ b/comet/api/endpoints/playback.py @@ -181,8 +181,9 @@ async def _cache_download_link_safely(**kwargs) -> None: ) -@router.get( +@router.api_route( "/{b64config}/playback/{hash}/{service_index}/{index}/{season}/{episode}", + methods=["GET", "HEAD"], tags=["Stremio"], summary="Playback Proxy", description="Proxies the playback request to the Debrid service or returns a cached link.",