Skip to main content

read_header_value

Function read_header_value 

Source
pub fn read_header_value(
    name: String,
    source: impl Read,
    max_len: usize,
) -> Result<HealthCheckHeaderValue, HeaderValueReadError>
Expand description

Read one health-check header value from source (a file or stdin) into a protected ingress carrier.

At most max_len + 3 bytes are read: the value, a possible terminal CRLF and one byte that proves an overflow. The bytes are kept exactly, except one terminal LF and the CR right before it, which a text editor or echo adds. Nothing else is trimmed, and an empty value is a value. The value is validated later, where the carrier is turned into a SecretValue.

The read buffer is allocated once at its final size, so no earlier, unwiped copy is left behind by a reallocation, and it is zeroed on every return. Neither the bytes nor any length of them appears in an error.