/// <summary> /// Retrieves the article headers for the specified range. Since this iterates over the article identifiers and /// that range may contain identifiers that are not legal (i.e. they don't exist on the server), this method will /// catch NNTP RFC 997 423 response codes and therefore skip the article identifier. /// </summary> /// <param name="firstArticleId">The first article id.</param> /// <param name="lastArticleId">The last article id.</param> /// <returns></returns> public virtual IEnumerable <ArticleHeadersDictionary> RetrieveArticleHeaders(int firstArticleId, int lastArticleId) { if (!CurrentGroupSelected) { throw new NntpGroupNotSelectedException(); } for (; firstArticleId < lastArticleId; firstArticleId++) { ArticleHeadersDictionary d = null; try { d = RetrieveArticleHeader(firstArticleId); } catch (NntpResponseException error) { if (error.LastResponseCode == 423) { continue; } throw error; } yield return(d); } }
/// <summary> /// Retrieves the article headers for the specified range. /// </summary> /// <param name="firstArticleId">The first article id.</param> /// <param name="lastArticleId">The last article id.</param> /// <returns></returns> public override IEnumerable <ArticleHeadersDictionary> RetrieveArticleHeaders(int firstArticleId, int lastArticleId) { if (!CurrentGroupSelected) { throw new NntpGroupNotSelectedException(); } if (m_supportsXover) { string[] headerNames = new string[] { "Article-ID", "Subject", "From", "Date", "Message-ID", "Xref", "Bytes", "Lines" }; foreach (string s in DoArticleCommand("XOVER " + firstArticleId + "-" + lastArticleId, 224)) { ArticleHeadersDictionary headers = new ArticleHeadersDictionary(); string[] fields = s.Split('\t'); for (int i = 0; i < headerNames.Length; i++) { headers.AddHeader(headerNames[i], fields[i]); } yield return(headers); } } else { // I can't use the base class to do this. for (; firstArticleId < lastArticleId; firstArticleId++) { yield return(RetrieveArticleHeader(firstArticleId)); } } }
/// <summary> /// Retrieves the article header common functionality. The command argument /// should be in the form "HEAD [article-id|message-id]." /// </summary> /// <param name="command">The command.</param> /// <returns></returns> protected ArticleHeadersDictionary RetrieveArticleHeaderCore(string command) { ArticleHeadersDictionary headers = new ArticleHeadersDictionary(); foreach (string s in DoArticleCommand(command, Rfc977ResponseCodes.ArticleRetrievedHeadFollows)) { if (s.Length == 0) { break; } else { headers.AddHeader(s); } } return(headers); }