#35631: Include quality value when parsing Accept header
-------------------------------+---------------------------------------
     Reporter:  Jake Howard    |                    Owner:  Jake Howard
         Type:  New feature    |                   Status:  assigned
    Component:  HTTP handling  |                  Version:  5.0
     Severity:  Normal         |               Resolution:
     Keywords:                 |             Triage Stage:  Accepted
    Has patch:  0              |      Needs documentation:  0
  Needs tests:  0              |  Patch needs improvement:  0
Easy pickings:  0              |                    UI/UX:  0
-------------------------------+---------------------------------------
Changes (by Carlton Gibson):

 * stage:  Unreviewed => Accepted

Comment:

 I think step 3 should read "Sort Request.accepted_types by quality value
 and specificity", e.g. `text/*;q=0.8,text/html;q=0.8` should be sorted
 `text/html` first.

 This is probably a sensible proposal. I suspect most people are not
 sending the quality value, so `1` is assumed and it has no effect.
 Nonetheless why not allow it?

 We'd need a new helper API on HttpRequest taking a set of mime types to
 match against, since the specificity question (`text/*`) makes it slightly
 more complex than just returning the first match in accepted_types from
 the set.

 DRF has implementations of this logic that can be used for reference:

 * [https://github.com/encode/django-rest-
 
framework/blob/8e304e1adbb0f99f91a15ed3abd379104bba3b89/rest_framework/negotiation.py#L53-L76
 rest_framework/negotiation.py#L53-L76]
 * [https://github.com/encode/django-rest-
 
framework/blob/8e304e1adbb0f99f91a15ed3abd379104bba3b89/rest_framework/utils/mediatypes.py#L27-L81
 rest_framework/utils/mediatypes.py#L27-L81]
-- 
Ticket URL: <https://code.djangoproject.com/ticket/35631#comment:1>
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 on the web visit 
https://groups.google.com/d/msgid/django-updates/01070190edf82616-de401f6e-00d0-413f-a63b-6a82bc6ee296-000000%40eu-central-1.amazonses.com.

Reply via email to