public HttpResponse GetResponse(HttpRequest request, CookieContainer cookies)
        {
            if (OsInfo.IsMonoRuntime && request.Url.Scheme == "https")
            {
                if (!_curlTLSFallbackCache.Find(request.Url.Host))
                {
                    try
                    {
                        return(_managedDispatcher.GetResponse(request, cookies));
                    }
                    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.", request.Url.Host);

                            _curlTLSFallbackCache.Set(request.Url.Host, true);
                        }
                        else
                        {
                            throw;
                        }
                    }
                }

                if (CurlHttpDispatcher.CheckAvailability())
                {
                    return(_curlDispatcher.GetResponse(request, cookies));
                }

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

            return(_managedDispatcher.GetResponse(request, cookies));
        }
Example #2
0
 public FallbackHttpDispatcher(ManagedHttpDispatcher managedDispatcher, CurlHttpDispatcher curlDispatcher, ICacheManager cacheManager, Logger logger)
 {
     _managedDispatcher    = managedDispatcher;
     _curlDispatcher       = curlDispatcher;
     _curlTLSFallbackCache = cacheManager.GetCache <bool>(GetType(), "curlTLSFallback");
     _logger = logger;
 }
 public FallbackHttpDispatcher(ICached <bool> curlTLSFallbackCache, Logger logger)
 {
     _logger = logger;
     _curlTLSFallbackCache = curlTLSFallbackCache;
     _managedDispatcher    = new ManagedHttpDispatcher();
     _curlDispatcher       = new CurlHttpDispatcher();
 }
 public FallbackHttpDispatcher(ICached<bool> curlTLSFallbackCache, Logger logger)
 {
     _logger = logger;
     _curlTLSFallbackCache = curlTLSFallbackCache;
     _managedDispatcher = new ManagedHttpDispatcher();
     _curlDispatcher = new CurlHttpDispatcher();
 }