#36447: HttpRequest.get_preferred_type misorders types when more specific
accepted
types have lower q
--------------------------------------+------------------------------------
Reporter: Anders Kaseorg | Owner: (none)
Type: Bug | Status: new
Component: HTTP handling | Version: 5.2
Severity: Normal | Resolution:
Keywords: preferred media type | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------
Comment (by Anders Kaseorg):
Just to point out a real-world example—Firefox sends `<video>` requests
with [https://developer.mozilla.org/en-
US/docs/Web/HTTP/Guides/Content_negotiation/List_of_default_Accept_values#values_for_a_video
this Accept header]:
{{{
Accept:
video/webm,video/ogg,video/*;q=0.9,application/ogg;q=0.7,audio/*;q=0.6,*/*;q=0.5
}}}
which Django incorrectly interprets as a preference for application/ogg
over video/*:
{{{
>>> request = HttpRequest()
>>> request.META["HTTP_ACCEPT"] =
"video/webm,video/ogg,video/*;q=0.9,application/ogg;q=0.7,audio/*;q=0.6,*/*;q=0.5"
>>> request.get_preferred_type(["video/mp4", "application/ogg"])
'application/ogg'
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/36447#comment:5>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion visit
https://groups.google.com/d/msgid/django-updates/010701975613f59e-01620a45-b5b0-4fde-acbc-c5183d60eeef-000000%40eu-central-1.amazonses.com.