File tree Expand file tree Collapse file tree 1 file changed +4
-2
lines changed
Expand file tree Collapse file tree 1 file changed +4
-2
lines changed Original file line number Diff line number Diff line change @@ -697,13 +697,15 @@ protected virtual MediaTypeHeaderValueMs SelectResponseContentType(HttpContext c
697697 } else if ( acceptHeaders . Count > 0 ) {
698698 // enumerate through each content type and see if it matches a supported content type
699699 // give priority to specific types, then to types with wildcards
700- foreach ( var acceptHeader in acceptHeaders . OrderBy ( x => x . MatchesAllTypes ? 4 : x . MatchesAllSubTypes ? 3 : x . MatchesAllSubTypesWithoutSuffix ? 2 : 1 ) ) {
700+ var sortedAcceptHeaders = acceptHeaders
701+ . OrderByDescending ( x => x . Quality ?? 1.0 )
702+ . ThenBy ( x => x . MatchesAllTypes ? 4 : x . MatchesAllSubTypes ? 3 : x . MatchesAllSubTypesWithoutSuffix ? 2 : 1 ) ;
703+ foreach ( var acceptHeader in sortedAcceptHeaders ) {
701704 var response = IsSupportedMediaType ( acceptHeader ) ;
702705 if ( response != null )
703706 return response ;
704707 }
705708 }
706-
707709 // return the default content type if no match is found, or if there is no 'Accept' header
708710 return _options . DefaultResponseContentType ;
709711 }
You can’t perform that action at this time.
0 commit comments