예제 #1
0
        /// <summary>
        /// Perform HttpRequest.
        /// </summary>
        /// <param name="http_request"></param>
        /// <param name="send_cookies"></param>
        /// <returns></returns>
        public bool Do(HttpRequest http_request, bool send_cookies)
        {
            if (AutoRotateProxy)
            {
                ChangeProxy();
            }

            int  attempt_count = 0;
            bool rc;

            while (true)
            {
                attempt_count++;
                rc = _do(http_request, send_cookies);
                if (rc)
                {
                    break;
                }
                if (Proxy != null)
                {
                    if (web_routine_status != WebRoutineStatus.EXCEPTION &&
                        HWResponse.StatusCode != HttpStatusCode.ProxyAuthenticationRequired &&
                        HWResponse.StatusCode != HttpStatusCode.GatewayTimeout &&
                        HWResponse.StatusCode != HttpStatusCode.BadGateway
                        )
                    {
                        break;
                    }

                    Proxies.Delete(Proxy);
                    if (attempt_count >= Settings.Proxy.MaxAttemptCountWithNewProxy)
                    {
                        Log.Error("Attempt quota exeeded: " + attempt_count.ToString());
                        break;
                    }
                    ChangeProxy();
                }
                if (attempt_count >= MaxAttemptCount)
                {
                    break;
                }
                Log.Write("Attempt #: " + attempt_count.ToString());
            }
            return(rc);
        }
예제 #2
0
 ///// <summary>
 ///// get next proxy from proxy queue
 ///// </summary>
 public void ChangeProxy()
 {
     this.Proxy = Proxies.Next();
 }