ExAthena.Lsp.Framing (ExAthena v0.7.1)

Copy Markdown View Source

Pure decoder for LSP's Content-Length-prefixed JSON-RPC framing.

The wire format is:

Content-Length: <N>\r\n
[Content-Type: ...]\r\n
\r\n
<N bytes of JSON>

parse/1 returns all complete frame bodies found in the buffer (as raw binaries — callers are responsible for Jason.decode!/1) and the unconsumed tail. Garbage bytes before the first Content-Length: token are dropped with a warning; this keeps the stream live if the server emits a startup banner before its first LSP frame.

Summary

Functions

Parse one or more LSP frames from buffer.

Functions

parse(buffer)

@spec parse(binary()) :: {[binary()], binary()}

Parse one or more LSP frames from buffer.

Returns {bodies, remainder} where bodies is a list of raw JSON binaries (in order) and remainder is whatever bytes follow the last complete frame.