Add Message::received_all() to iterate over all Received header fields (closes #146)

This commit is contained in:
Maurus Decimus
2026-06-21 08:12:03 +02:00
parent a13fe5c32d
commit 0128bc1da0
4 changed files with 38 additions and 1 deletions
+8 -1
View File
@@ -248,7 +248,7 @@ impl<'x> Message<'x> {
.unwrap_or(&HeaderValue::Empty)
}
/// Returns the first Received header field
/// Returns the last Received header field
pub fn received(&self) -> Option<&Received<'x>> {
self.parts[0]
.headers
@@ -256,6 +256,13 @@ impl<'x> Message<'x> {
.and_then(|header| header.as_received())
}
/// Returns an iterator over all Received header fields, in the order they
/// appear in the message.
pub fn received_all(&self) -> impl Iterator<Item = &Received<'x>> + Sync + Send {
self.header_values(HeaderName::Received)
.filter_map(|header| header.as_received())
}
/// Returns all References header fields
pub fn references(&self) -> &HeaderValue<'x> {
self.parts[0]
+1
View File
@@ -243,6 +243,7 @@ impl MessageParser {
// Attempt to recover contents of an invalid message
let mut is_encoding_problem = offset_end == usize::MAX;
eprintln!("DBG part={} ct={:?} mime_type={:?} is_text={} is_inline={} enc_problem={} offset_end={}", state.parts, content_type.map(|c| format!("{}/{}", c.ctype(), c.subtype().unwrap_or(""))), mime_type, is_text, is_inline, is_encoding_problem, offset_end as i64);
if is_encoding_problem {
encoding = Encoding::None;
if mime_type != MimeType::TextPlain {