* @param {AbortCallback} abort * @param {Blob} body * @param {import('./client.js')} client * @param {import('../core/request.js')} request * @param {import('net').Socket} socket * @param {number} contentLength * @param {string} header * @param {boolean} expectsPayload * @returns {Promise<vo
(abort, body, client, request, socket, contentLength, header, expectsPayload)
| 1515 | * @returns {Promise<void>} |
| 1516 | */ |
| 1517 | async function writeBlob (abort, body, client, request, socket, contentLength, header, expectsPayload) { |
| 1518 | try { |
| 1519 | if (contentLength != null && contentLength !== body.size) { |
| 1520 | throw new RequestContentLengthMismatchError() |
| 1521 | } |
| 1522 | |
| 1523 | const buffer = Buffer.from(await body.arrayBuffer()) |
| 1524 | |
| 1525 | socket.cork() |
| 1526 | socket.write(`${header}content-length: ${contentLength}\r\n\r\n`, 'latin1') |
| 1527 | socket.write(buffer) |
| 1528 | socket.uncork() |
| 1529 | |
| 1530 | request.onBodySent(buffer) |
| 1531 | request.onRequestSent() |
| 1532 | |
| 1533 | if (!expectsPayload && request.reset !== false) { |
| 1534 | socket[kReset] = true |
| 1535 | } |
| 1536 | |
| 1537 | client[kResume]() |
| 1538 | } catch (err) { |
| 1539 | abort(err) |
| 1540 | } |
| 1541 | } |
| 1542 | |
| 1543 | /** |
| 1544 | * @param {AbortCallback} abort |
no test coverage detected
searching dependent graphs…