public RSSUnitOfWork(IResource feed, bool parseItems, bool acceptHtmlIfXmlError) { Trace.WriteLineIf(Settings.Trace, "Starting update of feed " + feed.DisplayName); _feed = feed; _parseItems = parseItems; _acceptHtmlIfXmlError = acceptHtmlIfXmlError; _statusWriter = Core.UIManager.GetStatusWriter(this, StatusPane.Network); string feedUrl = feed.GetStringProp(Props.URL); if (!HttpReader.IsSupportedProtocol(feedUrl)) { throw new ArgumentException("Unsupported feed protocol: " + feedUrl); } if (parseItems) { FavIconManager favIconManager = (FavIconManager)Core.GetComponentImplementation(typeof(FavIconManager)); favIconManager.DownloadFavIcon(feedUrl); } _httpReader = new HttpReader(feedUrl); string etag = feed.GetPropText(Props.ETag); if (etag.Length > 0) { _httpReader.IfNoneMatch = etag; } string httpUserName = feed.GetStringProp(Props.HttpUserName); string httpPassword = feed.GetStringProp(Props.HttpPassword); if (httpUserName != null && httpPassword != null) { _httpReader.Credentials = new NetworkCredential(httpUserName, httpPassword); } _httpReader.AcceptInstanceManipulation = "feed"; if (_feed.HasProp(Props.DisableCompression) || Settings.DisableCompression) { _httpReader.AcceptEncoding = null; } _httpReader.CookieProvider = CookiesManager.GetUserCookieProvider(typeof(RSSUnitOfWork)); _status = RSSWorkStatus.NotStarted; Timeout = Settings.TimeoutInSec * 1000; OnTimeout += RSSUnitOfWork_OnTimeout; }
public FavoriteJob(IResource webLink, string URL) { _webLink = webLink; _statusWriter = Core.UIManager.GetStatusWriter(this, StatusPane.Network); _reader = new HttpReader(URL); Timeout = Core.SettingStore.ReadInt( "Favorites", "DownloadTimeout", 60000); // 1 minute in milliseconds OnTimeout += new MethodInvoker(_reader_OnTimeout); string ifNoneMatch = _webLink.GetPropText(FavoritesPlugin._propETag); if (ifNoneMatch.Length > 0) { _reader.IfNoneMatch = ifNoneMatch; } _reader.IfModifiedSince = LastModified(); _reader.CookieProvider = CookiesManager.GetUserCookieProvider(typeof(FavoriteJob)); _lastState = _reader.CurrentState; }