Beispiel #1
0
        private HttpResponse ExecuteRequest(HttpRequest request, HttpWebRequest webRequest)
        {
            if (OsInfo.IsMonoRuntime && webRequest.RequestUri.Scheme == "https")
            {
                if (!_curlTLSFallbackCache.Find(webRequest.RequestUri.Host))
                {
                    try
                    {
                        return(ExecuteWebRequest(request, webRequest));
                    }
                    catch (Exception ex)
                    {
                        if (ex.ToString().Contains("The authentication or decryption has failed."))
                        {
                            _logger.Debug("https request failed in tls error for {0}, trying curl fallback.", webRequest.RequestUri.Host);

                            _curlTLSFallbackCache.Set(webRequest.RequestUri.Host, true);
                        }
                        else
                        {
                            throw;
                        }
                    }
                }

                if (CurlHttpClient.CheckAvailability())
                {
                    return(ExecuteCurlRequest(request, webRequest));
                }

                _logger.Trace("Curl not available, using default WebClient.");
            }

            return(ExecuteWebRequest(request, webRequest));
        }
Beispiel #2
0
        private HttpResponse ExecuteCurlRequest(HttpRequest request, HttpWebRequest webRequest)
        {
            var curlClient = new CurlHttpClient();

            return(curlClient.GetResponse(request, webRequest));
        }