added hook for providing a proxy to HttpClientAdapter

This commit is contained in:
Brendan Forster
2014-01-15 16:40:44 -08:00
parent 364db535cd
commit 4105bc9119
2 changed files with 30 additions and 0 deletions

View File

@@ -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)
{