Skip to main content

parse_chunk_size

Function parse_chunk_size 

Source
pub fn parse_chunk_size(
    buf: &[u8],
) -> Result<Status<(usize, u64)>, InvalidChunkSize>
Expand description

Parse a buffer of bytes as a chunk size line.

The return value, if complete and successful, includes the position right after the line, where the chunk data starts, and the size of the chunk. A size of 0 is the last chunk.

The size is 1 to 16 hex digits and the line must end with CRLF. Chunk extensions are skipped, control characters other than HTAB are rejected in them.

ยงExample

let buf = b"4\r\nRust\r\n0\r\n\r\n";
assert_eq!(ntex_httparse::parse_chunk_size(buf),
           Ok(ntex_httparse::Status::Complete((3, 4))));