@zhengxs/http
Version:
A lightweight cross-platform http request library
45 lines (44 loc) • 1.23 kB
JavaScript
import { ReadStream as i } from "node:fs";
import "node:http";
import { Readable as l } from "node:stream";
import { ReadableStream as m } from "node:stream/web";
import a from "agentkeepalive";
import { FormDataEncoder as p } from "form-data-encoder";
import { M as d } from "../MultipartBody.mjs";
import { s as g } from "../registry.mjs";
const h = new a({
keepAlive: !0,
timeout: 5 * 60 * 1e3
}), u = new a.HttpsAgent({
keepAlive: !0,
timeout: 5 * 60 * 1e3
});
async function f(e, o) {
const t = new p(e), r = l.from(t), s = new d(r), n = {
...o.headers,
...t.headers,
"Content-Length": t.contentLength
};
return { ...o, body: s, headers: n };
}
function c() {
return {
kind: "node",
getMultipartRequestOptions: f,
getDefaultAgent: (e) => e.startsWith("https") ? u : h,
isFsReadStream: (e) => e instanceof i,
// Added in: v16.15.0
fetch: globalThis.fetch,
Request: globalThis.Request,
Response: globalThis.Response,
Headers: globalThis.Headers,
FormData: globalThis.FormData,
// Added in: v18.0.0
Blob: globalThis.Blob,
ReadableStream: m,
// Added in: v20.0.0
File: globalThis.File
};
}
g(c());
//# sourceMappingURL=nodenext.mjs.map