Expand description
LSP Content-Length header framing (Microsoft LSP base
protocol). Pure parser – no IO, no allocations beyond the
returned FrameHeader.
Content-Length: 47\r\n
Content-Type: application/vscode-jsonrpc; charset=utf-8\r\n
\r\n
{"jsonrpc":"2.0","method":"initialized","params":{}}The header block is ASCII; the body is UTF-8 JSON.
Content-Length is mandatory. Any other header – including the
optional Content-Type – is captured but not interpreted.
§Error model
Returns FrameError for ill-formed headers; the codec
propagates these as ProtocolError and tears down the
transport. A misbehaving server cannot wedge the editor: the
actor restarts the server with backoff (§5.4 crash recovery).
Structs§
- Frame
Header - One parsed LSP message header.
Enums§
- Frame
Error - Header-parse failures.
Constants§
- MAX_
MESSAGE_ BYTES - Per-message size ceiling. 64 MiB is comfortably above the largest realistic LSP payload (workspace symbol indices on huge monorepos sit in the few-megabyte range) while bounding memory pressure from a runaway server.
Functions§
- encode_
header - Encode a frame header for an outgoing message body of
body_lenbytes. Returns the ASCII header bytes including the trailing\r\n\r\nterminator – ready to be written before the body. Allocation-light: oneStringof bounded size. - parse_
header_ block - Parse the bytes of one header block (everything BEFORE the
\r\n\r\nterminator) into aFrameHeader. - parse_
header_ block_ with_ limit parse_header_blockwith an explicit ceiling. Tests use this to verify the bound is enforced; production paths go through the public wrapper.