mirror of https://github.com/abpframework/abp.git
committed by
GitHub
7 changed files with 58 additions and 31 deletions
@ -0,0 +1,29 @@ |
|||
using System; |
|||
using System.IO; |
|||
using System.Net.Http; |
|||
using System.Text; |
|||
|
|||
namespace Volo.Abp.Cli.Http |
|||
{ |
|||
public class CliHttpClient : HttpClient |
|||
{ |
|||
public CliHttpClient() : base(new CliHttpClientHandler()) |
|||
{ |
|||
Timeout = TimeSpan.FromSeconds(30); |
|||
|
|||
AddAuthentication(this); |
|||
} |
|||
|
|||
private static void AddAuthentication(HttpClient client) |
|||
{ |
|||
if (File.Exists(CliPaths.AccessToken)) |
|||
{ |
|||
var accessToken = File.ReadAllText(CliPaths.AccessToken, Encoding.UTF8); |
|||
if (!accessToken.IsNullOrEmpty()) |
|||
{ |
|||
client.SetBearerToken(accessToken); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,14 @@ |
|||
using System.Net; |
|||
using System.Net.Http; |
|||
|
|||
namespace Volo.Abp.Cli.Http |
|||
{ |
|||
public class CliHttpClientHandler : HttpClientHandler |
|||
{ |
|||
public CliHttpClientHandler() |
|||
{ |
|||
Proxy = WebRequest.GetSystemWebProxy(); |
|||
DefaultProxyCredentials = CredentialCache.DefaultCredentials; |
|||
} |
|||
} |
|||
} |
|||
Loading…
Reference in new issue