| 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); |