public IBrowsingResponse NavigateFile(Uri httpUrl, List <Tuple <string, string, Stream> > files, NameValueCollection postParamz) { if ((StoringFlags & StateStoringFlags.File) == StateStoringFlags.File) { var txtStr = httpUrl + ":" + String.Join(",", files.Select(d => d.Item2)); var key = "file_" + CalculateHash(txtStr); var hostTrigger = RootBrowsingStateTriggers.GetOrAddChild(httpUrl.Host, String.Format(message, httpUrl.Host)); var state = stateService.Get <StateBrowsingResponse>(key); if (state != null) { return(state); } var response = Parent.NavigateFile(httpUrl, files, postParamz); if (ShouldCache(response)) { stateService.Put <StateBrowsingResponse>(key, StateBrowsingResponse.Create(response), hostTrigger, (long)StoringDuration.TotalSeconds, txtStr); } return(response); } return(Parent.NavigateFile(httpUrl, files, postParamz)); }
protected virtual Uri GetNextProxyFor(IBrowsingSession session, string descriminator) { //TODO: optimize by caching the state lock (getNextProxyForLocker) { var ignoreIds = _stateService.Get <List <int> >("proxy_" + descriminator); if (ignoreIds == null) { ignoreIds = new List <int>(); } var proxy = WorkingProxies.FirstOrDefault(x => !ignoreIds.Contains(x.Id)); if (proxy == null) { _log.Warn("Proxy list ended and restared for " + descriminator); proxy = WorkingProxies.First(); ignoreIds = new List <int>(); } ignoreIds.Add(proxy.Id); var hostTrigger = RootDescriminatorStateTriggers .GetOrAddChild(descriminator, String.Format(message, descriminator)); _stateService.Put <List <int> >("proxy_" + descriminator, ignoreIds, hostTrigger, (long)StoringDuration.TotalSeconds); //_log.Debug(String.Format("Proxy changed for {0} to {1} at {2}", // descriminator, proxy, Thread.CurrentThread.ManagedThreadId)); session.ClearCookieContainer(); return(new Uri(proxy.IP)); } }