aboutsummaryrefslogtreecommitdiff
path: root/src/js/node/https.ts
blob: d75fb3132ea7b93f5184bf8f68a7214a96c97213 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
// Hardcoded module "node:https"
const http = require("node: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;
}

export default {
  ...http,
  get,
  request,
};