Skip to main content

read_payload

Function read_payload 

Source
pub fn read_payload<R: BufRead>(
    reader: &mut R,
) -> Result<Option<String>, String>
Expand description

Read a JSON-RPC payload from a buffered reader.

Reads headers until it finds Content-Length: N, then reads exactly N bytes of body. Returns None on EOF and Err on malformed input.

Behavioral contract (must be preserved by any caller relying on it): the Content-Length header match is case-insensitive, the body is read with read_exact for exactly N bytes, and a single optional trailing \r\n (or bare \n) between messages is consumed.