ContentLengthSession Type
A full-duplex Content-Length framed transport over a live process's stdin/stdout, suitable for LSP, DAP, BSP, and similar protocols. Construct it over a command started with `Command.KeepStdinOpen()`, enumerate `FramesAsync()`, and send raw payload bytes with `SendAsync`. The session owns the run's stdout consumption; other output verbs on the same handle are refused. `Command.StreamBuffer` bounds the unread frame backlog; leaving it unset preserves the default unbounded backlog. Only its two LOSSLESS full modes are honoured here: `Backpressure` paces the parser (and, through the pipe, the child) against your consumer, and `Error` faults the frame stream at the cap. The two DROP modes are refused at construction with a typed `ProcessError.Unsupported` — a framed transport carries protocol messages a peer correlates with its requests, so quietly deleting a queued frame is a corruption no consumer could detect, and this library refuses inapplicable configuration rather than downgrading it silently. With a bounded backlog, drain `FramesAsync()` concurrently with your sends rather than awaiting a send first: backpressure deliberately stops the parser (and the child) once the backlog is full, so a consumer that only starts reading after some other await can stall the child it is waiting on. The constructor itself never waits on the child — a `Command.Stdin(source)` feeder is awaited by the first `SendAsync`/`FinishInputAsync` instead, so the caller always gets the session back and can start draining frames.
Constructors
| Constructor |
Description
|
Full Usage:
ContentLengthSession(running)
Parameters:
RunningProcess
Returns: ContentLengthSession
|
A session using the default 16 MiB maximum payload size.
|
Full Usage:
ContentLengthSession(running, maxFrameBytes)
Parameters:
RunningProcess
maxFrameBytes : int
Returns: ContentLengthSession
|
|
Instance members
| Instance member |
Description
|
|
Close the child's framed input without cancellation. Equivalent to `FinishInputAsync(CancellationToken.None)`.
|
Full Usage:
this.FinishInputAsync
Parameters:
CancellationToken
Returns: Task<Result<unit, ProcessError>>
|
Close the child's framed input so it observes EOF. Sending is unsupported when the command did not keep stdin open; repeated close calls follow `ProcessStdin.FinishAsync`'s idempotent contract. Like `SendAsync`, this awaits a `Command.Stdin(source)` feeder first — closing the pipe under a still-writing feeder would truncate the source. `cancellationToken` bounds only the feeder and send-gate waits before delivery; once stdin is claimed and the gate is held, EOF delivery is not cancellable.
|
|
Enumerate incoming payloads. Headers are validated and omitted; each yielded array is exactly the advertised payload bytes. This single-consumer method may be called only once.
|
Full Usage:
this.MaxFrameBytes
Returns: int
|
The maximum payload size in bytes in either direction. Oversized incoming frames fail before allocating the payload; oversized sends are rejected before writing a header.
|
|
|
Full Usage:
this.SendAsync
Parameters:
byte[]
cancellationToken : CancellationToken
Returns: Task<Result<unit, ProcessError>>
|
Send one byte-exact payload. Concurrent calls are serialized so their headers and payloads cannot interleave. Cancellation may leave a partial frame in the child, so abandon the session after it — with one exception worth knowing: an interruption that lands while the call is still waiting for a `Command.Stdin(source)` feeder, or queued behind another send, has not written a byte. Both are reported the same way here; `JsonRpcSession`, layered on this type, tells them apart internally so a cancelled call does not end its conversation. On a `Command.Stdin(source)` + `KeepStdinOpen` run this is where the source feeder is awaited (the constructor no longer blocks on it), so the first send completes only once the source has been drained and the interactive writer is the pipe's single writer — `cancellationToken` bounds that wait too, reported as `ProcessError.Cancelled` like any other cancelled send.
|
ProcessKit API Reference