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
8888 public static Encoding GetEncoding ( this HttpContent httpContent )
8989 {
9090 var charSet = httpContent . Headers . ContentType ? . CharSet ;
91- if ( string . IsNullOrEmpty ( charSet ) || charSet == Encoding . UTF8 . WebName )
91+ if ( string . IsNullOrEmpty ( charSet ) == true )
9292 {
9393 return Encoding . UTF8 ;
9494 }
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 ( ) ) ;
96103 }
97104 }
98105}
You can’t perform that action at this time.
0 commit comments