pub struct Header {
pub name: SlicePos,
pub value: SlicePos,
}Expand description
Represents a parsed header.
Fields§
§name: SlicePosThe name portion of a header.
A header name must be valid ASCII-US, so it’s safe to store as a &str.
value: SlicePosThe value portion of a header.
While headers should be ASCII-US, the specification allows for values that may not be, and so the value is stored as bytes.
Implementations§
Source§impl Header
impl Header
Sourcepub fn parse(&mut self, src: &[u8]) -> Result<HeaderParsed>
pub fn parse(&mut self, src: &[u8]) -> Result<HeaderParsed>
Parse a buffer of bytes as header.
The return value, if complete and successful, includes the index of the buffer that parsing stopped at, and a sliced reference to the parsed headers. The length of the slice will be equal to the number of properly parsed headers.
§Example
use ntex_httparse::{Status, Header, HeaderParsed};
let buf = b"Host: foo.bar\nAccept: */*\n\nblah blah";
let mut header = Header::default();
assert_eq!(header.parse(buf), Ok(Status::Complete(HeaderParsed::Header(14))));pub fn parse_with_state( &mut self, src: &[u8], st: &mut State, ) -> Result<HeaderParsed>
Trait Implementations§
impl Copy for Header
impl Eq for Header
impl StructuralPartialEq for Header
Auto Trait Implementations§
impl Freeze for Header
impl RefUnwindSafe for Header
impl Send for Header
impl Sync for Header
impl Unpin for Header
impl UnsafeUnpin for Header
impl UnwindSafe for Header
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more