File tree Expand file tree Collapse file tree 1 file changed +20
-2
lines changed
Expand file tree Collapse file tree 1 file changed +20
-2
lines changed Original file line number Diff line number Diff line change 44using RestSharp ;
55using System ;
66using System . Net ;
7+ using System . Net . Http ;
78
89namespace Greg
910{
@@ -19,8 +20,6 @@ public IAuthProvider AuthProvider
1920
2021 public GregClient ( IAuthProvider provider , string packageManagerUrl )
2122 {
22-
23-
2423 // https://stackoverflow.com/questions/2819934/detect-windows-version-in-net
2524 // if the current OS is windows 7 or lower
2625 // set TLS to 1.2.
@@ -33,6 +32,25 @@ public GregClient(IAuthProvider provider, string packageManagerUrl)
3332 _client = new RestClient ( packageManagerUrl ) ;
3433 }
3534
35+ public GregClient ( IAuthProvider provider , string packageManagerUrl , HttpClient httpClient )
36+ {
37+ // https://stackoverflow.com/questions/2819934/detect-windows-version-in-net
38+ // if the current OS is windows 7 or lower
39+ // set TLS to 1.2.
40+ // else do nothing and let the OS decide the version of TLS to support. (.net 4.7 required)
41+ if ( System . Environment . OSVersion . Version . Major <= 6 && System . Environment . OSVersion . Version . Minor <= 1 )
42+ {
43+ ServicePointManager . SecurityProtocol |= SecurityProtocolType . Tls12 ;
44+ }
45+ _authProvider = provider ;
46+
47+ var baseUrl = new Uri ( packageManagerUrl ) ;
48+ if ( httpClient != null )
49+ _client = new RestClient ( httpClient , new RestClientOptions ( ) { BaseUrl = baseUrl } ) ;
50+ else
51+ _client = new RestClient ( packageManagerUrl ) ;
52+ }
53+
3654 private RestResponse ExecuteInternal ( Request m )
3755 {
3856
You can’t perform that action at this time.
0 commit comments