Ejemplo n.º 1
0
        /// <summary>Initialize the request thread.</summary>
        internal RequestThread(AsyncWebRequest asyncWebRequest)
        {
            myAsyncWebRequest = asyncWebRequest;
            _waitingRequests  = new PriorityQueue();
            _runningRequests  = 0;

            try
            {
                int newMax = Common.Configuration.ReadAppSettingsEntry("MaxDownloadThreads", DefaultMaxDownloadThreads);
                if (newMax > 0 && newMax < 50)
                {
                    _maxRequests = newMax;
                }
            }
            catch (ConfigurationErrorsException cex)
            {
                _log.Error("Failed to read 'MaxDownloadThreads' from .config", cex);
            }

            ThreadPool.QueueUserWorkItem(this.Run);
        }
Ejemplo n.º 2
0
        // this is marked obsolete by MS in the CLR 2.0
        public bool CheckValidationResult(ServicePoint sp, X509Certificate cert, WebRequest req, int problem)
        {
            try
            {
                if (problem != 0)
                {
                    // move bits around to get it casted from an signed int to a normal long enum type:
                    CertificateIssue issue = (CertificateIssue)(((problem << 1) >> 1) + 0x80000000);

                    // this is marked obsolete by MS in the CLR 2.0
                    // It seems also they has broken the old impl., we don't get a valid cert object now (handle is 0) on WinXP SP2
                    // via parameter, so we now use that of the servicepoint as a workaround:
                    CertificateIssueCancelEventArgs args = new CertificateIssueCancelEventArgs(issue, sp.Certificate, req, true);
                    AsyncWebRequest.RaiseOnCertificateIssue(sp, args);
                    return(!args.Cancel);
                }
            }
            catch (Exception ex)
            {
                Trace.WriteLine("TrustSelectedCertificatePolicy.CheckValidationResult() error: " + ex.Message);
            }
            // The 1.1 framework calls this method with a problem of 0, even if nothing is wrong
            return(problem == 0);
        }