()
| 52310 | }, instance); |
| 52311 | }, |
| 52312 | text() { |
| 52313 | return specConsumeBody(this, utf8DecodeBytes, instance); |
| 52314 | }, |
| 52315 | json() { |
| 52316 | return specConsumeBody(this, parseJSONFromBytes, instance); |
| 52317 | }, |
| 52318 | async formData() { |
| 52319 | webidl.brandCheck(this, instance); |
| 52320 | throwIfAborted(this[kState]); |
| 52321 | const contentType = this.headers.get("Content-Type"); |
| 52322 | if (/multipart\/form-data/.test(contentType)) { |
| 52323 | const headers = {}; |
| 52324 | for (const [key, value] of this.headers) headers[key.toLowerCase()] = value; |
| 52325 | const responseFormData = new FormData6(); |
| 52326 | let busboy; |
| 52327 | try { |
| 52328 | busboy = new Busboy({ |
| 52329 | headers, |
| 52330 | preservePath: true |
| 52331 | }); |
| 52332 | } catch (err) { |
| 52333 | throw new DOMException3(`${err}`, "AbortError"); |
| 52334 | } |
| 52335 | busboy.on("field", (name, value) => { |
| 52336 | responseFormData.append(name, value); |
| 52337 | }); |
| 52338 | busboy.on("file", (name, value, filename, encoding, mimeType) => { |
| 52339 | const chunks = []; |
| 52340 | if (encoding === "base64" || encoding.toLowerCase() === "base64") { |
| 52341 | let base64chunk = ""; |
| 52342 | value.on("data", (chunk) => { |
| 52343 | base64chunk += chunk.toString().replace(/[\r\n]/gm, ""); |
| 52344 | const end = base64chunk.length - base64chunk.length % 4; |
| 52345 | chunks.push(Buffer.from(base64chunk.slice(0, end), "base64")); |
| 52346 | base64chunk = base64chunk.slice(end); |
| 52347 | }); |
| 52348 | value.on("end", () => { |
| 52349 | chunks.push(Buffer.from(base64chunk, "base64")); |
| 52350 | responseFormData.append(name, new File5(chunks, filename, { type: mimeType })); |
| 52351 | }); |
| 52352 | } else { |
| 52353 | value.on("data", (chunk) => { |
| 52354 | chunks.push(chunk); |
| 52355 | }); |
| 52356 | value.on("end", () => { |
| 52357 | responseFormData.append(name, new File5(chunks, filename, { type: mimeType })); |
| 52358 | }); |
| 52359 | } |
| 52360 | }); |
| 52361 | const busboyResolve = new Promise((resolve, reject) => { |
| 52362 | busboy.on("finish", resolve); |
| 52363 | busboy.on("error", (err) => reject(new TypeError(err))); |
| 52364 | }); |
| 52365 | if (this.body !== null) for await (const chunk of consumeBody(this[kState].body)) busboy.write(chunk); |
| 52366 | busboy.end(); |
| 52367 | await busboyResolve; |
| 52368 | return responseFormData; |
| 52369 | } else if (/application\/x-www-form-urlencoded/.test(contentType)) { |
nothing calls this directly
no test coverage detected
searching dependent graphs…