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; }
public void BeginSession(RequestParams reqPrmsPattern, ResponseParams resPrmsPattern) { StartNewTransaction(reqPrmsPattern, resPrmsPattern); }
private void StartNewTransaction(RequestParams reqPrmsPattern, ResponseParams resPrmsPattern) { Transaction tr = new Transaction(reqPrmsPattern, resPrmsPattern, TransactionCallback); Transactions.Add(tr); if (Attempts > 0) { tr.Begin(); } else { SessionCallback(); } }
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; }
/// <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; }
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); }