-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
docs: hide Range header from flask to workaround beets web bug #41
base: main
Are you sure you want to change the base?
Conversation
6811070
to
3a661e4
Compare
3a661e4
to
26f6b2d
Compare
I just corrected my earlier assumption that streaming wasn't working because of flask 3 usage: Turns out I didn't use flask 3 actually but still 2. Nevertheless, streaming works with gstreamer and firefix only after I made this change. |
26f6b2d
to
83a3a60
Compare
83a3a60
to
91e25c2
Compare
Thank you for investigating this issue! Your changes hide all range-related headers from I feel a bit uncomfortable with adding the comment (otherwise I would just merge your proposal as it is, since it is an obvious improvement, anyway) |
e528018
to
414123f
Compare
I removed my unconfirmed suspicion from the comment now. Maybe flask supports range requests now but there was another problem in my setup/config? I won't investigate that now since I need an nginx reverse-proxy in front of it anyway now but I may come back to that later at some point eventually. |
Flask does support range requests and partial responses, but Beets web plugin does not. The plugin ignores any range request and will send the entire file each time (see here). Without any sort of proxy sorting this out (e.g. Given the plugin does not support partial responses, it should not advertise that it does. So it should not be responding with "Accept-Ranges: bytes". However, I can't see where it sets that response header. Do you have a log showing the traffic between GStreamer and Beets? It's interesting you need the extra nginx config settings, I would have thought |
The link you posted shows that
Thus, looking at the code, it seems flask fully supports range requests indeed but the beets web plugin breaks them by overwriting the |
I still can't see where that header processing function is called. But it would make sense that it is called. There was some flask issue showing a wrapped version of sendfile that handled range requests, it was more involved than just not overwriting that header but maybe it was old code. I don't use any of this, i was just curious! |
Removing that line within the beets web plugin really fixed the problem. I created a corresponding beets PR now. I suggest to merge this PR (since it is a valid workaround currently) and create/merge another one removing the workaround section within the readme as soon as the beet web plugin fix has been released (I anticipate it will be shipped with the beets 1.6.1 release). |
fyi the header processing is part of the |
414123f
to
e1ea321
Compare
I just updated the PR, simplifying the workaround, explaining that it is required prior to beets 1.6.1 only and linking to the PR that fixes the beets web plugin bug. Please re-review! |
This is to prevent flask from handling range requests when nginx is emulates range responses. Playing large opus files within firefox and gstreamer/mopidy worked for me only after I made this change in my nginx config. When using flask for streaming directly (without reverse-proxy), audio still doesn't play within firefox or gstreamer - prior to beets 1.6.1.
e1ea321
to
bca6dab
Compare
This is to prevent flask from handling range requests when nginx emulates range requests.
Playing large opus files within firefox and gstreamer/mopidy worked for me only after I made this change in my nginx config.
I guess this was not a problem previously since older flask versions did not support range queries at all but that seems to have changed partially since flask returns an
Accept-Ranges: bytes
header.Though, when using flask for streaming directly (without reverse-proxy), audio still doesn't play within firefox or gstreamer.
gstreamer logged an error indicating the request is unsupported.