From b9d05bf3f14ff2d8408c762f45a9f8e6ed94ccae Mon Sep 17 00:00:00 2001 From: Alexey Zimarev Date: Sun, 22 Oct 2017 14:53:37 +0200 Subject: [PATCH] Proxy issue --- RestSharp/Http.Async.cs | 3 +-- RestSharp/Http.Sync.cs | 3 +-- RestSharp/RestClient.cs | 16 ++++------------ 3 files changed, 6 insertions(+), 16 deletions(-) diff --git a/RestSharp/Http.Async.cs b/RestSharp/Http.Async.cs index c64f93a05..d6517d9b9 100644 --- a/RestSharp/Http.Async.cs +++ b/RestSharp/Http.Async.cs @@ -385,8 +385,7 @@ private HttpWebRequest ConfigureAsyncWebRequest(string method, Uri url) if (ReadWriteTimeout != 0) webRequest.ReadWriteTimeout = ReadWriteTimeout; - if (Proxy != null) - webRequest.Proxy = Proxy; + webRequest.Proxy = Proxy; if (CachePolicy != null) webRequest.CachePolicy = CachePolicy; diff --git a/RestSharp/Http.Sync.cs b/RestSharp/Http.Sync.cs index a8aabe32e..ccfe5a804 100644 --- a/RestSharp/Http.Sync.cs +++ b/RestSharp/Http.Sync.cs @@ -258,8 +258,7 @@ private HttpWebRequest ConfigureWebRequest(string method, Uri url) if (Credentials != null) webRequest.Credentials = Credentials; - if (Proxy != null) - webRequest.Proxy = Proxy; + webRequest.Proxy = Proxy; if (CachePolicy != null) webRequest.CachePolicy = CachePolicy; diff --git a/RestSharp/RestClient.cs b/RestSharp/RestClient.cs index b1e92fe68..da1c529b0 100644 --- a/RestSharp/RestClient.cs +++ b/RestSharp/RestClient.cs @@ -477,20 +477,12 @@ private void ConfigureHttp(IRestRequest request, IHttp http) }); } } - ConfigureProxy(http); - http.RemoteCertificateValidationCallback = RemoteCertificateValidationCallback; - } - - private void ConfigureProxy(IHttp http) - { - if (Proxy != null) - http.Proxy = Proxy; + http.Proxy = Proxy; #if NETSTANDARD2_0 - else - { - http.Proxy = new DefaultProxy(); - } + if (http.Proxy == null) + WebRequest.DefaultWebProxy = null; #endif + http.RemoteCertificateValidationCallback = RemoteCertificateValidationCallback; } private static RestResponse ConvertToRestResponse(IRestRequest request, HttpResponse httpResponse)