Download node_modules/@aws-sdk/node-http-handler/dist-es/write-request-body.js from sweet2004/bot: direct link, hf CLI and curl.
- Browser
- Download file 611 Bytes
-
https://huggingface.co/spaces/sweet2004/bot/resolve/main/node_modules/%40aws-sdk/node-http-handler/dist-es/write-request-body.js
- Command line
-
hf download hf://spaces/sweet2004/bot/node_modules/@aws-sdk/node-http-handler/dist-es/write-request-body.js
-
curl -L -o write-request-body.js https://huggingface.co/spaces/sweet2004/bot/resolve/main/node_modules/%40aws-sdk/node-http-handler/dist-es/write-request-body.js
611 Bytes
| import { Readable } from "stream"; | |
| export function writeRequestBody(httpRequest, request) { | |
| const expect = request.headers["Expect"] || request.headers["expect"]; | |
| if (expect === "100-continue") { | |
| httpRequest.on("continue", () => { | |
| writeBody(httpRequest, request.body); | |
| }); | |
| } | |
| else { | |
| writeBody(httpRequest, request.body); | |
| } | |
| } | |
| function writeBody(httpRequest, body) { | |
| if (body instanceof Readable) { | |
| body.pipe(httpRequest); | |
| } | |
| else if (body) { | |
| httpRequest.end(Buffer.from(body)); | |
| } | |
| else { | |
| httpRequest.end(); | |
| } | |
| } | |