File tree Expand file tree Collapse file tree 2 files changed +16
-1
lines changed
StandardSocketsHttpHandler Expand file tree Collapse file tree 2 files changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -8,7 +8,8 @@ internal static class HttpRequestMessageExtensions
88 {
99 public static bool HasHeaders ( this HttpRequestMessage request )
1010 {
11- string headersFieldName = "_headers" ;
11+ // Note: The field name is _headers in .NET core
12+ string headersFieldName = RuntimeUtils . IsDotNetFramework ( ) ? "headers" : "_headers" ;
1213 FieldInfo headersField = typeof ( HttpRequestMessage ) . GetField ( headersFieldName , BindingFlags . Instance | BindingFlags . NonPublic ) ;
1314 HttpRequestHeaders headers = ( HttpRequestHeaders ) headersField . GetValue ( request ) ;
1415 return headers != null ;
Original file line number Diff line number Diff line change 1+ using System . Runtime . InteropServices ;
2+
3+ namespace System
4+ {
5+ internal class RuntimeUtils
6+ {
7+ public static bool IsDotNetFramework ( )
8+ {
9+ const string DotnetFrameworkDescription = ".NET Framework" ;
10+ string frameworkDescription = RuntimeInformation . FrameworkDescription ;
11+ return frameworkDescription . StartsWith ( DotnetFrameworkDescription ) ;
12+ }
13+ }
14+ }
You can’t perform that action at this time.
0 commit comments