/// <summary> /// Posts the article. /// </summary> /// <param name="header">The header.</param> /// <param name="body">The body.</param> public virtual void PostArticle(IArticleHeaderEnumerator header, /*List*/ IEnumerable <string> body) { if (header == null) { throw new ArgumentNullException("header"); } if (body == null) { throw new ArgumentNullException("body"); } ValidateConnectionState(); NntpReaderWriter.WriteCommand("POST"); NntpReaderWriter.ReadResponse(); if (NntpReaderWriter.LastResponseCode != Rfc977ResponseCodes.SendArticleToPost) { throw new NntpResponseException(Resource.ErrorMessage06, NntpReaderWriter.LastResponse); } foreach (string key in header.HeaderKeys) { int count = 0; foreach (string v in header[key]) { if (count > 0) { NntpReaderWriter.Write("\t"); } else { NntpReaderWriter.Write(key); NntpReaderWriter.Write(": "); } NntpReaderWriter.WriteLine(v); count++; } } NntpReaderWriter.WriteLine(""); foreach (string s in body) { if (s.Length > 0 && s[0] == '.') { NntpReaderWriter.Write("."); } NntpReaderWriter.WriteLine(s); } NntpReaderWriter.WriteLine("."); NntpReaderWriter.ReadResponse(); if (NntpReaderWriter.LastResponseCode != Rfc977ResponseCodes.ArticlePostedOk) { Console.WriteLine("resp: {0}", NntpReaderWriter.LastResponse); throw new NntpResponseException(Resource.ErrorMessage07, NntpReaderWriter.LastResponse); } }
/// <summary> /// Posts the article. /// </summary> /// <param name="header">The header.</param> /// <param name="body">The body.</param> public virtual void PostArticle(IArticleHeaderEnumerator header, List <string> body) { sb.Clear(); if (header == null) { throw new ArgumentNullException("header"); } if (body == null) { throw new ArgumentNullException("body"); } ValidateConnectionState(); NntpReaderWriter.WriteCommand("post"); NntpReaderWriter.ReadResponse(); if (NntpReaderWriter.LastResponseCode != Rfc977ResponseCodes.SendArticleToPost) { throw new NntpResponseException(NntpErrorMessages.ERROR_6, NntpReaderWriter.LastResponse); } foreach (string key in header.HeaderKeys) { int count = 0; foreach (string v in header[key]) { if (count > 0) { sb.Append("\t"); } else { sb.Append(key); sb.Append(": "); } sb.Append(v + NEWLINE); count++; } } sb.Append("" + NEWLINE); foreach (string s in body) { if (s.Length > 0 && s[0] == '.') { sb.Append("."); } sb.Append(s + NEWLINE); } sb.Append("." + NEWLINE); NntpReaderWriter.Write(sb.ToString()); NntpReaderWriter.ReadResponse(); if (NntpReaderWriter.LastResponseCode != Rfc977ResponseCodes.ArticlePostedOk) { throw new NntpResponseException(NntpErrorMessages.ERROR_7, NntpReaderWriter.LastResponse); } }