aboutsummaryrefslogtreecommitdiff
path: root/src/js/node/https.ts
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <jarred@jarredsumner.com> 2023-07-11 19:14:34 -0700
committerGravatar GitHub <noreply@github.com> 2023-07-11 19:14:34 -0700
commitcbb88672f217a90db1aa1eb29cd92d5d9035b22b (patch)
tree43a00501f3cde495967e116f0b660777051551f8 /src/js/node/https.ts
parent1f900cff453700b19bca2acadfe26da4468c1282 (diff)
parent34b0e7a2bbd8bf8097341cdb0075d0908283e834 (diff)
downloadbun-cbb88672f217a90db1aa1eb29cd92d5d9035b22b.tar.gz
bun-cbb88672f217a90db1aa1eb29cd92d5d9035b22b.tar.zst
bun-cbb88672f217a90db1aa1eb29cd92d5d9035b22b.zip
Merge branch 'main' into jarred/esm-conditionsjarred/esm-conditions
Diffstat (limited to 'src/js/node/https.ts')
-rw-r--r--src/js/node/https.ts65
1 files changed, 65 insertions, 0 deletions
diff --git a/src/js/node/https.ts b/src/js/node/https.ts
new file mode 100644
index 000000000..08eb89a01
--- /dev/null
+++ b/src/js/node/https.ts
@@ -0,0 +1,65 @@
+// Hardcoded module "node:https"
+import * as http from "node:http";
+
+var {
+ Agent,
+ Server,
+ METHODS,
+ STATUS_CODES,
+ createServer,
+ ServerResponse,
+ IncomingMessage,
+ maxHeaderSize,
+ validateHeaderName,
+ validateHeaderValue,
+ globalAgent,
+} = http;
+
+function request(input, options, cb) {
+ if (input && typeof input === "object" && !(input instanceof URL)) {
+ input.protocol ??= "https:";
+ } else if (typeof options === "object") {
+ options.protocol ??= "https:";
+ }
+
+ return http.request(input, options, cb);
+}
+
+function get(input, options, cb) {
+ const req = request(input, options, cb);
+ req.end();
+ return req;
+}
+
+var defaultExport = {
+ Agent,
+ Server,
+ METHODS,
+ STATUS_CODES,
+ createServer,
+ ServerResponse,
+ IncomingMessage,
+ request,
+ get,
+ maxHeaderSize,
+ validateHeaderName,
+ validateHeaderValue,
+ globalAgent,
+};
+
+export {
+ Agent,
+ Server,
+ METHODS,
+ STATUS_CODES,
+ createServer,
+ ServerResponse,
+ IncomingMessage,
+ request,
+ get,
+ maxHeaderSize,
+ validateHeaderName,
+ validateHeaderValue,
+ globalAgent,
+};
+export default defaultExport;