| 26394 | super.addRequest(req, opts); |
| 26395 | } |
| 26396 | setRequestProps(req, opts) { |
| 26397 | const { proxy } = this; |
| 26398 | const protocol = opts.secureEndpoint ? "https:" : "http:"; |
| 26399 | const hostname = req.getHeader("host") || "localhost"; |
| 26400 | const base = `${protocol}//${hostname}`; |
| 26401 | const url2 = new url_1.URL(req.path, base); |
| 26402 | if (opts.port !== 80) { |
| 26403 | url2.port = String(opts.port); |
| 26404 | } |
| 26405 | req.path = String(url2); |
| 26406 | const headers = typeof this.proxyHeaders === "function" ? this.proxyHeaders() : { ...this.proxyHeaders }; |
| 26407 | if (proxy.username || proxy.password) { |
| 26408 | const auth = `${decodeURIComponent(proxy.username)}:${decodeURIComponent(proxy.password)}`; |
| 26409 | headers["Proxy-Authorization"] = `Basic ${Buffer.from(auth).toString("base64")}`; |
| 26410 | } |
| 26411 | if (!headers["Proxy-Connection"]) { |
| 26412 | headers["Proxy-Connection"] = this.keepAlive ? "Keep-Alive" : "close"; |
| 26413 | } |
| 26414 | for (const name of Object.keys(headers)) { |
| 26415 | const value = headers[name]; |
| 26416 | if (value) { |
| 26417 | req.setHeader(name, value); |
| 26418 | } |
| 26419 | } |
| 26420 | } |
| 26421 | async connect(req, opts) { |
| 26422 | req._header = null; |
| 26423 | if (!req.path.includes("://")) { |