MCPcopy Create free account
hub / github.com/dwgx/WindsurfAPI / wrapEnvelope

Function wrapEnvelope

src/connect.js:34–46  ·  view source on GitHub ↗
(protoBuf, { compress = true } = {})

Source from the content-addressed store, hash-verified

32 * Wrap protobuf bytes in a Connect-RPC envelope frame.
33 */
34export function wrapEnvelope(protoBuf, { compress = true } = {}) {
35 let payload = protoBuf;
36 let flags = 0;
37 if (compress && payload.length > 0) {
38 payload = gzipSync(payload);
39 flags |= 0x01;
40 }
41 const frame = Buffer.alloc(5 + payload.length);
42 frame[0] = flags;
43 frame.writeUInt32BE(payload.length, 1);
44 payload.copy(frame, 5);
45 return frame;
46}
47
48/**
49 * Wrap a request for sending (single envelope, gzipped).

Callers 3

responseBodyFunction · 0.90
responseBodyFunction · 0.90
wrapRequestFunction · 0.85

Calls

no outgoing calls

Tested by 2

responseBodyFunction · 0.72
responseBodyFunction · 0.72