| 220 | } |
| 221 | |
| 222 | export class Uint8ArrayBody implements RequestBody { |
| 223 | contentType?: string; |
| 224 | remainingData: Uint8Array; |
| 225 | |
| 226 | constructor(data: Uint8Array, contentType?: string) { |
| 227 | this.contentType = contentType; |
| 228 | this.remainingData = data; |
| 229 | } |
| 230 | |
| 231 | |
| 232 | setHeaders(headers: Record<string, string>) { |
| 233 | if (this.contentType) { |
| 234 | headers["Content-Type"] = this.contentType; |
| 235 | } |
| 236 | } |
| 237 | |
| 238 | async read(buf: Uint8Array) { |
| 239 | if (this.remainingData.length > 0) { |
| 240 | const readValues = this.remainingData.subarray(0, buf.length); |
| 241 | buf.set(readValues, 0); |
| 242 | this.remainingData = this.remainingData.subarray(readValues.length); |
| 243 | return readValues.length; |
| 244 | } |
| 245 | |
| 246 | return 0; |
| 247 | } |
| 248 | |
| 249 | } |
| 250 | |
| 251 | /** |
| 252 | * A response to a http request. |
nothing calls this directly
no outgoing calls
no test coverage detected