nodeHttpExecutor.js 1.2 KB

123456789101112131415161718192021222324
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.httpExecutor = exports.NodeHttpExecutor = void 0;
  4. const builder_util_runtime_1 = require("builder-util-runtime");
  5. const http_1 = require("http");
  6. const http_proxy_agent_1 = require("http-proxy-agent");
  7. const https = require("https");
  8. const https_proxy_agent_1 = require("https-proxy-agent");
  9. class NodeHttpExecutor extends builder_util_runtime_1.HttpExecutor {
  10. // noinspection JSMethodCanBeStatic
  11. // noinspection JSUnusedGlobalSymbols
  12. createRequest(options, callback) {
  13. if (process.env["https_proxy"] !== undefined && options.protocol === "https:") {
  14. options.agent = new https_proxy_agent_1.HttpsProxyAgent(process.env["https_proxy"]);
  15. }
  16. else if (process.env["http_proxy"] !== undefined && options.protocol === "http:") {
  17. options.agent = new http_proxy_agent_1.HttpProxyAgent(process.env["http_proxy"]);
  18. }
  19. return (options.protocol === "http:" ? http_1.request : https.request)(options, callback);
  20. }
  21. }
  22. exports.NodeHttpExecutor = NodeHttpExecutor;
  23. exports.httpExecutor = new NodeHttpExecutor();
  24. //# sourceMappingURL=nodeHttpExecutor.js.map