MCPcopy Create free account
hub / github.com/Zoo-Code-Org/Zoo-Code / encodeHeaders

Function encodeHeaders

apps/vscode-e2e/src/bedrock-mock-server.ts:17–36  ·  view source on GitHub ↗
(headers: Record<string, string>)

Source from the content-addressed store, hash-verified

15// aimock's builder nests the payload one level too deep (contentBlockDelta inside contentBlockDelta),
16// causing the AWS SDK deserializer's take() to miss the delta field entirely.
17function encodeHeaders(headers: Record<string, string>): Buffer {
18 const parts: Buffer[] = []
19 for (const [name, value] of Object.entries(headers)) {
20 const nameBytes = Buffer.from(name, "utf8")
21 const valueBytes = Buffer.from(value, "utf8")
22 const buf = Buffer.alloc(1 + nameBytes.length + 1 + 2 + valueBytes.length)
23 let off = 0
24 buf.writeUInt8(nameBytes.length, off)
25 off += 1
26 nameBytes.copy(buf, off)
27 off += nameBytes.length
28 buf.writeUInt8(7, off)
29 off += 1 // type 7 = string
30 buf.writeUInt16BE(valueBytes.length, off)
31 off += 2
32 valueBytes.copy(buf, off)
33 parts.push(buf)
34 }
35 return Buffer.concat(parts)
36}
37
38function encodeFrame(eventType: string, payload: object): Buffer {
39 const hdrs = encodeHeaders({

Callers 1

encodeFrameFunction · 0.85

Calls 2

entriesMethod · 0.80
fromMethod · 0.80

Tested by

no test coverage detected