1- // Copyright © myCSharp.de - all rights reserved
1+ // Copyright © https:// myCSharp.de - all rights reserved
22
33using Microsoft . AspNetCore . Http ;
44using Microsoft . Extensions . Primitives ;
@@ -23,13 +23,13 @@ public static class HttpClientHintsHttpContextExtensions
2323 public static HttpClientHints GetClientHints ( this HttpContext context )
2424 {
2525 // Check if client hints are already cached for this request
26- if ( context . Items . TryGetValue ( ClientHintsCacheKey , out var cached ) && cached is HttpClientHints hints )
26+ if ( context . Items . TryGetValue ( ClientHintsCacheKey , out object ? cached ) && cached is HttpClientHints hints )
2727 {
2828 return hints ;
2929 }
30-
30+
3131 // Create and cache new client hints
32- var newHints = context . Request . Headers . GetClientHints ( ) ;
32+ HttpClientHints newHints = context . Request . Headers . GetClientHints ( ) ;
3333 context . Items [ ClientHintsCacheKey ] = newHints ;
3434 return newHints ;
3535 }
@@ -44,14 +44,14 @@ public static HttpClientHints GetClientHints(this IHeaderDictionary headers)
4444 // User Agent
4545 headers . TryGetValue ( "User-Agent" , out StringValues userAgentValues ) ;
4646 string ? userAgent = userAgentValues . Count > 0 ? userAgentValues [ 0 ] : null ;
47-
47+
4848 headers . TryGetValue ( "Sec-CH-UA" , out StringValues uaValues ) ;
4949 string ? ua = uaValues . Count > 0 ? uaValues [ 0 ] : null ;
5050
5151 // Platform
5252 headers . TryGetValue ( "Sec-CH-UA-Platform" , out StringValues platformValues ) ;
5353 string ? platform = platformValues . Count > 0 ? platformValues [ 0 ] : null ;
54-
54+
5555 headers . TryGetValue ( "Sec-CH-UA-Platform-Version" , out StringValues platformVersionValues ) ;
5656 string ? platformVersion = platformVersionValues . Count > 0 ? platformVersionValues [ 0 ] : null ;
5757
@@ -66,7 +66,7 @@ public static HttpClientHints GetClientHints(this IHeaderDictionary headers)
6666 // Device
6767 headers . TryGetValue ( "Sec-CH-UA-Model" , out StringValues modelValues ) ;
6868 string ? model = modelValues . Count > 0 ? modelValues [ 0 ] : null ;
69-
69+
7070 headers . TryGetValue ( "Sec-CH-UA-Mobile" , out StringValues mobileValues ) ;
7171 bool ? mobile = HttpClientHintsInterpreter . IsMobile ( mobileValues . Count > 0 ? mobileValues [ 0 ] : null ) ;
7272
0 commit comments