fromwerkzeug.datastructuresimportLanguageAcceptfromwerkzeug.httpimportparse_accept_headera=parse_accept_header("en-US,fr-FR", LanguageAccept)
asserta.best=="en-US"# fails, it returns fr-FR
I expected the order to be preserved.
RFC 3282 describes desired behavior for Accept-Language: "If no Q values are given, the language-ranges are given in priority order, with the leftmost language-range being the most preferred language; this is an extension to the HTTP/1.1 rules, but matches current practice."
Looking at the source code, the Accept class is reverse-sorting the input list by specificity, then quality, then name; I think it should not sort by name and instead should preserve the given order.
The text was updated successfully, but these errors were encountered:
According to current standard which is RFC 7231 I'd rather expect a list in case of equal preference matches. There is a note there describing this exact case.
I expected the order to be preserved.
RFC 3282 describes desired behavior for Accept-Language: "If no Q values are given, the language-ranges are given in priority order, with the leftmost language-range being the most preferred language; this is an extension to the HTTP/1.1 rules, but matches current practice."
Looking at the source code, the Accept class is reverse-sorting the input list by specificity, then quality, then name; I think it should not sort by name and instead should preserve the given order.
The text was updated successfully, but these errors were encountered: