Don't throw error if ping fails

This commit is contained in:
Zaid Abdulla committed 2019-11-23 12:36:12 -08:00
1 parent 612563f171
commit 07a5c96e2a
1 file changed
+5 -1
+5 -1
View File
@@ -593,7 +593,11 @@ export function listener(request, response): void {
const host = querystring.unescape(PING_REGEX.exec(urlParts.pathname)[1]);
ping(host, (err, res, stdout) => {
if (err) {
if (!res) throwError(err, response);
if (!res) {
response.writeHead(500, { Connection: "close" });
response.end(`${err.name}: ${err.message}`);
return;
}
response.writeHead(404, { "Cache-Control": "no-cache" });
response.end(`${err.name}: ${err.message}`);
return;