mirror of
https://github.com/stalwartlabs/mail-parser.git
synced 2026-11-29 08:01:21 +00:00
Add Message::received_all() to iterate over all Received header fields (closes #146)
This commit is contained in:
+8
-1
@@ -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]
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user