Parse the end of the header section
This commit is contained in:
parent
10c5968676
commit
a7824e9657
2 changed files with 7 additions and 4 deletions
|
@ -10,7 +10,7 @@ use nom::{
|
||||||
sequence::tuple,
|
sequence::tuple,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::abnf::{fws, vchar_seq};
|
use crate::abnf::{fws, vchar_seq, perm_crlf};
|
||||||
use crate::model::HeaderSection;
|
use crate::model::HeaderSection;
|
||||||
|
|
||||||
/// HEADERS
|
/// HEADERS
|
||||||
|
@ -19,7 +19,7 @@ use crate::model::HeaderSection;
|
||||||
///
|
///
|
||||||
/// See: https://www.rfc-editor.org/rfc/rfc5322.html#section-2.2
|
/// See: https://www.rfc-editor.org/rfc/rfc5322.html#section-2.2
|
||||||
pub fn header_section(input: &str) -> IResult<&str, HeaderSection> {
|
pub fn header_section(input: &str) -> IResult<&str, HeaderSection> {
|
||||||
fold_many0(
|
let (input, headers) = fold_many0(
|
||||||
header_field,
|
header_field,
|
||||||
HeaderSection::default,
|
HeaderSection::default,
|
||||||
|mut section, head| {
|
|mut section, head| {
|
||||||
|
@ -34,7 +34,10 @@ pub fn header_section(input: &str) -> IResult<&str, HeaderSection> {
|
||||||
};
|
};
|
||||||
section
|
section
|
||||||
}
|
}
|
||||||
)(input)
|
)(input)?;
|
||||||
|
|
||||||
|
let (input, _) = perm_crlf(input)?;
|
||||||
|
Ok((input, headers))
|
||||||
}
|
}
|
||||||
|
|
||||||
enum HeaderField<'a> {
|
enum HeaderField<'a> {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use imf_codec::headers;
|
use imf_codec::headers;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let header = "Subject: Hello\r\n World\r\nFrom: <quentin@deuxfleurs.fr>\r\n\r\n";
|
let header = "Subject: Hello\r\n World\r\nFrom: <quentin@deuxfleurs.fr>\r\n\r\nHello world";
|
||||||
println!("{:?}", headers::header_section(header));
|
println!("{:?}", headers::header_section(header));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue