File tree Expand file tree Collapse file tree 1 file changed +9
-2
lines changed
WebApiClientCore/System.Net.Http Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -88,11 +88,18 @@ public static async Task<byte[]> ReadAsByteArrayAsync(this HttpContent httpConte
88
88
public static Encoding GetEncoding ( this HttpContent httpContent )
89
89
{
90
90
var charSet = httpContent . Headers . ContentType ? . CharSet ;
91
- if ( string . IsNullOrEmpty ( charSet ) || charSet == Encoding . UTF8 . WebName )
91
+ if ( string . IsNullOrEmpty ( charSet ) == true )
92
92
{
93
93
return Encoding . UTF8 ;
94
94
}
95
- return Encoding . GetEncoding ( charSet ) ;
95
+
96
+ var span = charSet . AsSpan ( ) . TrimStart ( '"' ) . TrimEnd ( '"' ) ;
97
+ if ( span . Equals ( Encoding . UTF8 . WebName , StringComparison . OrdinalIgnoreCase ) )
98
+ {
99
+ return Encoding . UTF8 ;
100
+ }
101
+
102
+ return Encoding . GetEncoding ( span . ToString ( ) ) ;
96
103
}
97
104
}
98
105
}
You can’t perform that action at this time.
0 commit comments