Skip to main content

decode_chunked

Function decode_chunked 

Source
pub fn decode_chunked(input: &[u8], cap: usize) -> Result<Vec<u8>, NetError>
Expand description

Decode a complete Transfer-Encoding: chunked body.

The decoded body is capped at cap bytes. Chunk extensions and trailer lines are accepted, but the body must contain the terminal empty trailer line (0\r\n\r\n for a response without trailers).

ยงExamples

use sim_lib_net_core::decode_chunked;

let decoded = decode_chunked(b"4\r\nWiki\r\n5\r\npedia\r\n0\r\n\r\n", 32).unwrap();
assert_eq!(decoded, b"Wikipedia");