MCPcopy Create free account
hub / github.com/WICG/webpackage / addResponse

Method addResponse

js/bundle/src/encoder.ts:93–101  ·  view source on GitHub ↗
(headerMap: HeaderMap, payload: Uint8Array)

Source from the content-addressed store, hash-verified

91 // Adds a response to `this.response`, and returns its length in the
92 // responses section.
93 private addResponse(headerMap: HeaderMap, payload: Uint8Array): number {
94 if (payload.length > 0 && !headerMap.has('content-type')) {
95 throw new Error('Non-empty exchange must have Content-Type header');
96 }
97
98 const response = [headerMap.toCBOR(), payload];
99 this.responses.push(response);
100 return encodedLength(response);
101 }
102
103 private addIndexEntry(url: string, responseLength: number) {
104 this.compatAdapter.setIndexEntry(url, responseLength);

Callers 1

addExchangeMethod · 0.95

Calls 1

toCBORMethod · 0.80

Tested by

no test coverage detected