Skip to main content

try_encode_length

Function try_encode_length 

pub fn try_encode_length<B>(buf: &mut B, len: u32) -> Result<(), ProtocolError>
where B: BufMut,
Available on crate feature fastcgi only.
Expand description

Encode len using the FastCGI variable-length integer format into buf.

Lengths 0–127 are written as 1 byte; lengths 128–(2^31 − 1) as 4 bytes. Returns ProtocolError::ContentTooLarge when len > MAX_NV_LENGTH, since the high bit of the 4-byte form is reserved as a marker.

Reference: FastCGI Specification §3.4