From 6b929c6e72565a107270e81dec3a262cabb831e1 Mon Sep 17 00:00:00 2001 From: Max Goltzsche Date: Wed, 20 Dec 2023 00:49:34 +0100 Subject: [PATCH] web: fix range request support Do not let the web plugin overwrite the Content-Length header with the full file length since flask/werkzeug sets the requested range's/chunk's size when handling a range request. This allows to play large audio/opus files using e.g. a browser/firefox or gstreamer/mopidy without making a reverse-proxy/nginx emulate range request support and hide range-related headers from the backend. --- beetsplug/web/__init__.py | 1 - docs/changelog.rst | 2 ++ 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/beetsplug/web/__init__.py b/beetsplug/web/__init__.py index cebb0be0a..cd7e8a3fc 100644 --- a/beetsplug/web/__init__.py +++ b/beetsplug/web/__init__.py @@ -336,7 +336,6 @@ def item_file(item_id): response = flask.send_file( item_path, as_attachment=True, download_name=safe_filename ) - response.headers["Content-Length"] = os.path.getsize(item_path) return response diff --git a/docs/changelog.rst b/docs/changelog.rst index 73cc10f3d..b3b63f1c2 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -279,6 +279,8 @@ Bug fixes: :bug:`4973` * Fix bug regarding displaying tracks that have been changed not being displayed unless the detail configuration is enabled. +* :doc:`/plugins/web`: Fix range request support, allowing to play large audio/ + opus files using e.g. a browser/firefox or gstreamer/mopidy directly. For plugin developers: