@@ -214,13 +214,14 @@ static int Main(string[] args)
214214
215215 var content = ParseHttpContent ( verb , _parameters ) ;
216216 var headers = _parameters . GetValue < Dictionary < string , List < string > > > ( "-h" , requires : false ) ;
217+ var http2 = _parameters . Get ( "-http2" , requires : false ) != null ;
217218 _parameters . ThrowIfUnknown ( ) ;
218219
219220 var uri = Utils . EnsureAbsoluteUri ( path , persistentAuthHelper ) ;
220221 var accessToken = Utils . GetDefaultToken ( ) ;
221222 if ( ! String . IsNullOrEmpty ( accessToken ) )
222223 {
223- return HttpInvoke ( uri , new TokenCacheInfo { AccessToken = accessToken } , verb , verbose , content , headers ) . Result ;
224+ return HttpInvoke ( uri , new TokenCacheInfo { AccessToken = accessToken } , verb , verbose , content , headers , http2 ) . Result ;
224225 }
225226
226227 var env = ARMConfiguration . GetEnvironmentByRequest ( uri ) ?? Utils . GetDefaultEnv ( ) ;
@@ -233,7 +234,7 @@ static int Main(string[] args)
233234 var resource = GetResource ( uri , persistentAuthHelper . ARMConfiguration ) ;
234235 var subscriptionId = GetTenantOrSubscription ( uri ) ;
235236 var cacheInfo = persistentAuthHelper . GetToken ( subscriptionId , resource ) . Result ?? persistentAuthHelper . GetTokenByResource ( resource ) . Result ;
236- return HttpInvoke ( uri , cacheInfo , verb , verbose , content , headers ) . Result ;
237+ return HttpInvoke ( uri , cacheInfo , verb , verbose , content , headers , http2 ) . Result ;
237238 }
238239 else
239240 {
@@ -359,8 +360,9 @@ static void PrintUsage()
359360
360361 Console . WriteLine ( ) ;
361362 Console . WriteLine ( "Call ARM api" ) ;
362- Console . WriteLine ( " ARMClient.exe [get|post|put|patch|delete] [url] (<@file|content>) (-h \" header: value\" ) (-verbose)" ) ;
363+ Console . WriteLine ( " ARMClient.exe [get|post|put|patch|delete] [url] (<@file|content>) (-h \" header: value\" ) (-verbose) (-http2) " ) ;
363364 Console . WriteLine ( " Use '-h' multiple times to add more than one custom HTTP header." ) ;
365+ Console . WriteLine ( " Use '-http2' to force http/2." ) ;
364366
365367 Console . WriteLine ( ) ;
366368 Console . WriteLine ( "Copy token to clipboard" ) ;
@@ -417,9 +419,15 @@ static HttpContent ParseHttpContent(string verb, CommandLineParameters parameter
417419 return null ;
418420 }
419421
420- static async Task < int > HttpInvoke ( Uri uri , TokenCacheInfo cacheInfo , string verb , bool verbose , HttpContent content , Dictionary < string , List < string > > headers )
422+ static async Task < int > HttpInvoke ( Uri uri , TokenCacheInfo cacheInfo , string verb , bool verbose , HttpContent content , Dictionary < string , List < string > > headers , bool http2 )
421423 {
422- var handler = new HttpLoggingHandler ( new HttpClientHandler ( ) , verbose ) ;
424+ var winhttp = http2 ? new WinHttpHandler ( ) : null ;
425+ if ( Utils . GetSkipSslVerify ( ) && winhttp != null )
426+ {
427+ winhttp . ServerCertificateValidationCallback = delegate { return true ; } ;
428+ }
429+
430+ var handler = new HttpLoggingHandler ( ( HttpMessageHandler ) winhttp ?? new HttpClientHandler ( ) , verbose ) ;
423431 return await Utils . HttpInvoke ( uri , cacheInfo , verb , handler , content , headers ) ;
424432 }
425433
0 commit comments