pub struct Fields(/* private fields */);Expand description
The field lines of a request or a response, in the order they arrived.
A list rather than a map, because a field section is a list: RFC 9110 §5.3 lets a name repeat, and the order of the values under one name is part of what they mean. Lookups walk it, which for the two or three fields a CONNECT request carries is what any map would have done more slowly.
Names are compared without regard to case. On the wire they are lowercase
already – RFC 9114 §4.2 makes an uppercase one malformed, and
super::stream enforces it – so the folding is not what makes a lookup
find the field; it is what keeps a lookup from depending on that rule holding
somewhere else.
Implementations§
Source§impl Fields
impl Fields
Sourcepub fn append(&mut self, name: impl Into<Box<str>>, value: FieldValue)
pub fn append(&mut self, name: impl Into<Box<str>>, value: FieldValue)
Adds a field, keeping every value a repeated name already had.
The name must be a lowercase token, since it goes on the wire as it is
given and RFC 9114 §4.2 makes an uppercase one malformed. Asserted in
debug builds, and for the reason FieldValue::from_static gives: every
name this server appends is a literal in this tree or one
field_name has already accepted, so a violation is a bug rather than
something a peer can provoke – and a release build has no business
panicking over it.
Sourcepub fn get(&self, name: &str) -> Option<&FieldValue>
pub fn get(&self, name: &str) -> Option<&FieldValue>
The first value of name, or None if there is none.
Sourcepub fn get_all<'a>(
&'a self,
name: &'a str,
) -> impl Iterator<Item = &'a FieldValue>
pub fn get_all<'a>( &'a self, name: &'a str, ) -> impl Iterator<Item = &'a FieldValue>
Every value of name, in the order they arrived.
Sourcepub fn iter(&self) -> impl Iterator<Item = (&str, &FieldValue)>
pub fn iter(&self) -> impl Iterator<Item = (&str, &FieldValue)>
Every field line, in the order they arrived.