File tree 2 files changed +21
-7
lines changed
2 files changed +21
-7
lines changed Original file line number Diff line number Diff line change 15
15
using System . Globalization ;
16
16
using System . Reflection ;
17
17
using System . Text ;
18
+ using System . Text . RegularExpressions ;
18
19
using System . Threading . Tasks ;
19
20
20
21
namespace Box . V2 . Managers
@@ -379,12 +380,21 @@ private string CheckFor45PlusVersion(int releaseKey)
379
380
private string GetNetCoreVersion ( )
380
381
{
381
382
var assembly = typeof ( System . Runtime . GCSettings ) . GetTypeInfo ( ) . Assembly ;
382
- var assemblyPath = assembly . CodeBase . Split ( new [ ] { '/' , '\\ ' } , StringSplitOptions . RemoveEmptyEntries ) ;
383
- var netCoreAppIndex = Array . IndexOf ( assemblyPath , "Microsoft.NETCore.App" ) ;
384
- return netCoreAppIndex > 0 && netCoreAppIndex < assemblyPath . Length - 2 ?
385
- assemblyPath [ netCoreAppIndex + 1 ] :
386
- null ;
387
- }
383
+ if ( assembly ? . CodeBase != null )
384
+ {
385
+ var assemblyPath = assembly . CodeBase . Split ( new [ ] { '/' , '\\ ' } , StringSplitOptions . RemoveEmptyEntries ) ;
386
+ var netCoreAppIndex = Array . IndexOf ( assemblyPath , "Microsoft.NETCore.App" ) ;
387
+ return netCoreAppIndex > 0 && netCoreAppIndex < assemblyPath . Length - 2 ?
388
+ assemblyPath [ netCoreAppIndex + 1 ] :
389
+ null ;
390
+ }
388
391
392
+ #if NETSTANDARD2_0
393
+ var frameworkVersion = System . Runtime . InteropServices . RuntimeInformation . FrameworkDescription ;
394
+ return Regex . Match ( frameworkVersion , @"\d+(\.\d+)+" ) . Value ;
395
+ #else
396
+ return null ;
397
+ #endif
398
+ }
389
399
}
390
400
}
Original file line number Diff line number Diff line change @@ -269,7 +269,11 @@ private class ClientFactory
269
269
270
270
private static HttpClient CreateClient ( bool followRedirect , IWebProxy webProxy )
271
271
{
272
- var handler = new HttpClientHandler ( ) { AutomaticDecompression = DecompressionMethods . Deflate | DecompressionMethods . GZip } ;
272
+ var handler = new HttpClientHandler ( ) ;
273
+ if ( handler . SupportsAutomaticDecompression )
274
+ {
275
+ handler . AutomaticDecompression = DecompressionMethods . Deflate | DecompressionMethods . GZip ;
276
+ }
273
277
handler . AllowAutoRedirect = followRedirect ;
274
278
275
279
if ( webProxy != null )
You can’t perform that action at this time.
0 commit comments