({ h2stream, body, client, request: request3, socket, contentLength, header, expectsPayload })
| 55189 | } |
| 55190 | }; |
| 55191 | body.on("data", onData).on("end", onFinished).on("error", onFinished).on("close", onAbort); |
| 55192 | if (body.resume) { |
| 55193 | body.resume(); |
| 55194 | } |
| 55195 | socket.on("drain", onDrain).on("error", onFinished); |
| 55196 | } |
| 55197 | async function writeBlob({ h2stream, body, client, request: request3, socket, contentLength, header, expectsPayload }) { |
| 55198 | assert2(contentLength === body.size, "blob body must have content length"); |
| 55199 | const isH2 = client[kHTTPConnVersion] === "h2"; |
| 55200 | try { |
| 55201 | if (contentLength != null && contentLength !== body.size) { |
| 55202 | throw new RequestContentLengthMismatchError(); |
| 55203 | } |
| 55204 | const buffer = Buffer.from(await body.arrayBuffer()); |
| 55205 | if (isH2) { |
| 55206 | h2stream.cork(); |
| 55207 | h2stream.write(buffer); |
| 55208 | h2stream.uncork(); |
| 55209 | } else { |
| 55210 | socket.cork(); |
| 55211 | socket.write(`${header}content-length: ${contentLength}\r |
| 55212 | \r |
| 55213 | `, "latin1"); |
| 55214 | socket.write(buffer); |
| 55215 | socket.uncork(); |
| 55216 | } |
| 55217 | request3.onBodySent(buffer); |
| 55218 | request3.onRequestSent(); |
| 55219 | if (!expectsPayload) { |
| 55220 | socket[kReset] = true; |
| 55221 | } |
| 55222 | resume2(client); |
| 55223 | } catch (err) { |
no test coverage detected
searching dependent graphs…