| 190 | |
| 191 | /** This class represents an HTTP resource in Web Bundle. */ |
| 192 | export class Response { |
| 193 | status: number; |
| 194 | headers: Headers; |
| 195 | body: Uint8Array; |
| 196 | |
| 197 | constructor(responsesSectionItem: unknown[]) { |
| 198 | if (responsesSectionItem.length !== 2) { |
| 199 | throw new Error('Wrong response structure'); |
| 200 | } |
| 201 | const { status, headers } = decodeResponseMap( |
| 202 | asBytestring(responsesSectionItem[0]) |
| 203 | ); |
| 204 | this.status = status; |
| 205 | this.headers = headers; |
| 206 | this.body = asBytestring(responsesSectionItem[1]); |
| 207 | } |
| 208 | } |
| 209 | |
| 210 | function decodeResponseMap(cbor: Uint8Array): { |
| 211 | status: number; |
nothing calls this directly
no outgoing calls
no test coverage detected