Merge pull request #1362 from benphelps/feature/ping-4xx

Accept http 401 / 403 for ping
pull/1366/head
shamoon 2 years ago committed by GitHub
commit 9b6755e87e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -25,7 +25,7 @@ export default function Ping({ service }) {
const statusText = `${service.ping}: HTTP status ${data.status}`; const statusText = `${service.ping}: HTTP status ${data.status}`;
if (data && data.status !== 200) { if (data.status > 403) {
return ( return (
<div className="w-auto px-1.5 py-0.5 text-center bg-theme-500/10 dark:bg-theme-900/50 rounded-b-[3px] overflow-hidden" title={statusText}> <div className="w-auto px-1.5 py-0.5 text-center bg-theme-500/10 dark:bg-theme-900/50 rounded-b-[3px] overflow-hidden" title={statusText}>
<div className="text-[8px] font-bold text-rose-500/80">{data.status}</div> <div className="text-[8px] font-bold text-rose-500/80">{data.status}</div>
@ -33,12 +33,10 @@ export default function Ping({ service }) {
); );
} }
if (data && data.status === 200) { return (
return ( <div className="w-auto px-1.5 py-0.5 text-center bg-theme-500/10 dark:bg-theme-900/50 rounded-b-[3px] overflow-hidden" title={statusText}>
<div className="w-auto px-1.5 py-0.5 text-center bg-theme-500/10 dark:bg-theme-900/50 rounded-b-[3px] overflow-hidden" title={statusText}> <div className="text-[8px] font-bold text-emerald-500/80">{t("common.ms", { value: data.latency, style: "unit", unit: "millisecond", unitDisplay: "narrow", maximumFractionDigits: 0 })}</div>
<div className="text-[8px] font-bold text-emerald-500/80">{t("common.ms", { value: data.latency, style: "unit", unit: "millisecond", unitDisplay: "narrow", maximumFractionDigits: 0 })}</div> </div>
</div> );
);
}
} }

@ -21,7 +21,7 @@ export default async function handler(req, res) {
}); });
let endTime = performance.now(); let endTime = performance.now();
if (status >= 400) { if (status > 403) {
// try one more time as a GET in case HEAD is rejected for whatever reason // try one more time as a GET in case HEAD is rejected for whatever reason
startTime = performance.now(); startTime = performance.now();
[status] = await httpProxy(pingURL); [status] = await httpProxy(pingURL);

Loading…
Cancel
Save