mirror of
https://github.com/zoriya/octokit.net.git
synced 2025-12-20 14:15:12 +00:00
added hook for providing a proxy to HttpClientAdapter
This commit is contained in:
@@ -36,6 +36,21 @@ namespace Octokit
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new connection instance used to make requests of the GitHub API.
|
||||
/// </summary>
|
||||
/// <param name="productInformation">
|
||||
/// The name (and optionally version) of the product using this library. This is sent to the server as part of
|
||||
/// the user agent for analytics purposes.
|
||||
/// </param>
|
||||
/// <param name="httpClient">
|
||||
/// The client to use for executing requests
|
||||
/// </param>
|
||||
public Connection(ProductHeaderValue productInformation, IHttpClient httpClient)
|
||||
: this(productInformation, _defaultGitHubApiUrl, _anonymousCredentials, httpClient, new SimpleJsonSerializer())
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new connection instance used to make requests of the GitHub API.
|
||||
/// </summary>
|
||||
|
||||
@@ -18,6 +18,15 @@ namespace Octokit.Internal
|
||||
/// </remarks>
|
||||
public class HttpClientAdapter : IHttpClient
|
||||
{
|
||||
readonly IWebProxy webProxy;
|
||||
|
||||
public HttpClientAdapter() { }
|
||||
|
||||
public HttpClientAdapter(IWebProxy webProxy)
|
||||
{
|
||||
this.webProxy = webProxy;
|
||||
}
|
||||
|
||||
public async Task<IResponse<T>> Send<T>(IRequest request)
|
||||
{
|
||||
Ensure.ArgumentNotNull(request, "request");
|
||||
@@ -30,6 +39,12 @@ namespace Octokit.Internal
|
||||
{
|
||||
httpOptions.AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate;
|
||||
}
|
||||
if (httpOptions.SupportsProxy && webProxy != null)
|
||||
{
|
||||
httpOptions.UseProxy = true;
|
||||
httpOptions.Proxy = webProxy;
|
||||
}
|
||||
|
||||
|
||||
var http = new HttpClient(httpOptions)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user