summaryrefslogtreecommitdiff
path: root/src/diagnostics.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/diagnostics.rs')
-rw-r--r--src/diagnostics.rs17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/diagnostics.rs b/src/diagnostics.rs
index 432a801..f6ed82a 100644
--- a/src/diagnostics.rs
+++ b/src/diagnostics.rs
@@ -104,6 +104,10 @@ pub async fn measure(
!content_type.contains("html"),
"Diagnostic endpoint returned HTML"
);
+ ensure!(
+ !content_type.contains("application/problem+"),
+ "Diagnostic endpoint returned an error document"
+ );
let status = response.status().as_u16();
let stream = response.bytes_stream().map_err(std::io::Error::other);
let mut reader = tokio_util::io::StreamReader::new(stream);
@@ -154,6 +158,19 @@ pub async fn measure(
!prefix.starts_with("<!doctype html") && !prefix.starts_with("<html"),
"Diagnostic endpoint returned an HTML document"
);
+ let json_error = serde_json::from_str::<serde_json::Value>(&prefix)
+ .ok()
+ .is_some_and(|body| {
+ ["error", "errors"].iter().any(|key| {
+ body.get(key).is_some_and(|value| {
+ !value.is_null() && value != false && value != 0 && value != ""
+ })
+ })
+ });
+ ensure!(
+ !json_error,
+ "Diagnostic endpoint returned an error document"
+ );
ensure!(!speed || bytes > 0, "Speed response contained no data");
if !speed && settings.ping_url == Settings::default().ping_url {
ensure!(