Skip to content

Commit dcd7647

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

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,37 +500,41 @@ 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
var url = "";
506506
if (options.target.socketPath) {
507-
options.target.hostname = 'localhost'
508-
url = options.target.toString().substring(5) // chop off unix+
507+
options.target.hostname = "localhost";
508+
url = options.target.toString().substring(5); // chop off unix+
509509
} else {
510-
url = options.target.toString()
510+
url = options.target.toString();
511511
}
512512

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

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

0 commit comments

Comments
 (0)