smolter
API

send

Write a web Response to a Node ServerResponse.

Compatibility

ReactServer/build API, not a browser import.
React SSRAvailable to this renderer's SSR integration; browser event handlers run after hydration.
PreactServer/build API, not a browser import.
Preact SSRAvailable to this renderer's SSR integration; browser event handlers run after hydration.

Import from @kasperrt/smolter/utils/http

Signature

function send(response: Response, outgoing: StreamingResponse);

Parameters

Pass response and the outgoing Node response.

Returns

Returns Promise<void> after streaming the response body with backpressure.

Usage

Write a web Response to a Node ServerResponse.

await send(response, res);

Behavior and limits

Preserves status, headers and separate Set-Cookie headers. Secure cookies are relaxed for local non-production HTTP. Streams response chunks with backpressure and calls an available compression flush method. If the Node response has already ended or closed, cancels the unread body without writing headers. A clean client disconnect cancels streaming without rejecting; genuine source, destination and cancellation failures still propagate.

View implementation ↗