Skip to content

Commit 8e381f6

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 4337046 commit 8e381f6

File tree

1 file changed

+26
-22
lines changed

1 file changed

+26
-22
lines changed

lib/configproxy.js

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -500,36 +500,40 @@ export class ConfigurableProxy extends EventEmitter {
500500
options.method = "GET";
501501

502502
options.target.searchParams.set("url", req.url);
503-
options.target.pathname = options.target.pathname + code.toString()
503+
options.target.pathname = options.target.pathname + code.toString();
504504

505505
if (options.target.socketPath) {
506-
options.target.hostname = 'localhost'
507-
var url = options.target.toString().substring(5) // chop off unix+
506+
options.target.hostname = "localhost";
507+
var url = options.target.toString().substring(5); // chop off unix+
508508
} else {
509-
var url = options.target.toString()
509+
var url = options.target.toString();
510510
}
511511

512512
this.log.debug("Requesting custom error page: %s", url);
513513

514-
var errorRequest = (options.secure ? https : http).request(url, options.target, (upstream) => {
515-
if (res.writableEnded) {
516-
// response already done
517-
// make sure to consume upstream;
518-
upstream.resume();
519-
return;
514+
var errorRequest = (options.secure ? https : http).request(
515+
url,
516+
options.target,
517+
(upstream) => {
518+
if (res.writableEnded) {
519+
// response already done
520+
// make sure to consume upstream;
521+
upstream.resume();
522+
return;
523+
}
524+
["content-type", "content-encoding"].map((key) => {
525+
if (!upstream.headers[key]) return;
526+
if (res.setHeader) res.setHeader(key, upstream.headers[key]);
527+
});
528+
if (res.writeHead) res.writeHead(code);
529+
upstream.on("data", (data) => {
530+
if (res.write && !res.writableEnded) res.write(data);
531+
});
532+
upstream.on("end", () => {
533+
if (res.end) res.end();
534+
});
520535
}
521-
["content-type", "content-encoding"].map((key) => {
522-
if (!upstream.headers[key]) return;
523-
if (res.setHeader) res.setHeader(key, upstream.headers[key]);
524-
});
525-
if (res.writeHead) res.writeHead(code);
526-
upstream.on("data", (data) => {
527-
if (res.write && !res.writableEnded) res.write(data);
528-
});
529-
upstream.on("end", () => {
530-
if (res.end) res.end();
531-
});
532-
});
536+
);
533537
errorRequest.on("error", (e) => {
534538
// custom error failed, fallback on default
535539
this.log.error("Failed to get custom error page: %s", e);

0 commit comments

Comments
 (0)