File tree 1 file changed +11
-3
lines changed
src/Http/Http.Extensions/src 1 file changed +11
-3
lines changed Original file line number Diff line number Diff line change 2
2
// The .NET Foundation licenses this file to you under the MIT license.
3
3
4
4
using System . Diagnostics . CodeAnalysis ;
5
- using System . Linq ;
6
5
using System . Text . Json . Serialization ;
7
6
using Microsoft . AspNetCore . Mvc ;
8
7
using Microsoft . Extensions . Options ;
@@ -26,9 +25,18 @@ public bool CanWrite(ProblemDetailsContext context)
26
25
var httpContext = context . HttpContext ;
27
26
var acceptHeader = httpContext . Request . Headers . Accept . GetList < MediaTypeHeaderValue > ( ) ;
28
27
29
- if ( acceptHeader ? . Any ( h => _jsonMediaType . IsSubsetOf ( h ) || _problemDetailsJsonMediaType . IsSubsetOf ( h ) ) == true )
28
+ if ( acceptHeader is { Count : > 0 } )
30
29
{
31
- return true ;
30
+ for ( var i = 0 ; i < acceptHeader . Count ; i ++ )
31
+ {
32
+ var acceptHeaderValue = acceptHeader [ i ] ;
33
+
34
+ if ( _jsonMediaType . IsSubsetOf ( acceptHeaderValue ) ||
35
+ _problemDetailsJsonMediaType . IsSubsetOf ( acceptHeaderValue ) )
36
+ {
37
+ return true ;
38
+ }
39
+ }
32
40
}
33
41
34
42
return false ;
You can’t perform that action at this time.
0 commit comments