Function parsip::parse_headers [] [src]

pub fn parse_headers<'b: 'h, 'h>(
    input: &'b [u8],
    headers: &'h mut [Header<'b>]
) -> IResult<&'b [u8], &'h [Header<'b>]>

Parse a buffer of bytes as headers.

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

let buf = b"Host: foo.bar\r\nAccept: */*\r\n\r\n";
let mut headers = [parsip::EMPTY_HEADER; 4];
assert_eq!(parsip::parse_headers(buf, &mut headers),
           parsip::IResult::Done(&buf[28..], &[
               parsip::Header { name: "Host", value: b"foo.bar" },
               parsip::Header { name: "Accept", value: b"*/*" }
           ][..]));