Esempio n. 1
0
        public Transaction(RequestParams reqPrms, ResponseParams resPrms, Action<Transaction> callBack)
        {
            if (callBack==null)
                throw new ArgumentNullException("Transaction callback can not be null");

            _callBack = callBack;

            Result = TransactionResult.Initialized;
            Stage = TransactionStage.Initial;
        }
Esempio n. 2
0
 public void BeginSession(RequestParams reqPrmsPattern, ResponseParams resPrmsPattern)
 {
     StartNewTransaction(reqPrmsPattern, resPrmsPattern);
 }
Esempio n. 3
0
        private void StartNewTransaction(RequestParams reqPrmsPattern, ResponseParams resPrmsPattern)
        {
            Transaction tr = new Transaction(reqPrmsPattern, resPrmsPattern, TransactionCallback);
            Transactions.Add(tr);

            if (Attempts > 0)
            {
                tr.Begin();
            }
            else
            {
                SessionCallback();
            }
        }
Esempio n. 4
0
 public void BeginSession(RequestParams reqPrmsPattern, ResponseParams resPrmsPattern)
 {
     StartNewTransaction(reqPrmsPattern, resPrmsPattern);
 }
Esempio n. 5
0
        HttpWebRequest CreateRequest(Uri uri, CookieOptions cookieOptions, TimingParams param, RequestParams requestParam, RatedProxy proxy, CookieCollection insertCookie)
        {
            HttpWebRequest request = HttpWebRequest.Create(uri) as HttpWebRequest;

            request.Headers = requestParam.Headers;
            request.UserAgent = requestParam.UserAgent;
            request.Host = uri.Host;
            request.Accept = requestParam.Accept;
            request.ContentType = requestParam.ContentType;
            //request.Referer = "http://www.google.com/";
            request.AllowAutoRedirect = requestParam.UseRedirect;
            request.KeepAlive = requestParam.KeepAlive;
            request.AutomaticDecompression = System.Net.DecompressionMethods.Deflate | System.Net.DecompressionMethods.GZip;
            request.Proxy = proxy;
            request.Timeout = param.RequestTimeout;
            request.ReadWriteTimeout = param.GetStreamTimeout;
            request.CookieContainer = BuildCookieContainer(cookieOptions, insertCookie);
            request.Method = requestParam.Method;

            return request;
        }
Esempio n. 6
0
        /// <summary>
        /// WARRING: some of the reference fields of cloned object is reference assigning
        /// </summary>
        /// <returns></returns>
        public object Clone()
        {
            RequestParams clone =  new RequestParams()
                       {
                           Uri = new Uri(this.Uri.OriginalString),
                           PrxContainer = this.PrxContainer,                //Reference assigning
                           Cookie = this.Cookie,                            //Reference assigning
                           PostData = this.PostData,
                           Decompression = this.Decompression,
                           RequestTimeout = this.RequestTimeout,
                           Headers =  this.Headers,                         //Reference assigning
                           KeepAlive = this.KeepAlive,
                           Method = this.Method
                       };

            return clone;
        }
Esempio n. 7
0
        HttpWebRequest CreateRequest(Uri uri, CookieOptions cookieOptions, TimingParams param, RequestParams requestParam, RatedProxy proxy, CookieCollection insertCookie)
        {
            HttpWebRequest request = HttpWebRequest.Create(uri) as HttpWebRequest;

            request.Headers     = requestParam.Headers;
            request.UserAgent   = requestParam.UserAgent;
            request.Host        = uri.Host;
            request.Accept      = requestParam.Accept;
            request.ContentType = requestParam.ContentType;
            //request.Referer = "http://www.google.com/";
            request.AllowAutoRedirect      = requestParam.UseRedirect;
            request.KeepAlive              = requestParam.KeepAlive;
            request.AutomaticDecompression = System.Net.DecompressionMethods.Deflate | System.Net.DecompressionMethods.GZip;
            request.Proxy            = proxy;
            request.Timeout          = param.RequestTimeout;
            request.ReadWriteTimeout = param.GetStreamTimeout;
            request.CookieContainer  = BuildCookieContainer(cookieOptions, insertCookie);
            request.Method           = requestParam.Method;

            return(request);
        }