Changes
diff --git a/prd.md b/prd.md
index f07ab2a..51d69da 100644
--- a/prd.md
+++ b/prd.md
@@ -15,7 +15,7 @@ A simple self-hosted service status tracker.
- It monitors a bunch of endpoints which are defined in the
config file
- Endpoints may be monitored by one of the following protocols:
- * HTTP (check it returns 2xx status)
+ * HTTP (check it returns 2xx or 3xx status)
* TCP or UDP port open
* ICMP
- Possible config snippet for endpoint:
diff --git a/src/probe.cpp b/src/probe.cpp
index 5003d97..0f6edb2 100644
--- a/src/probe.cpp
+++ b/src/probe.cpp
@@ -157,7 +157,7 @@ mw::E<ProbeStatus> check(const HttpEndpoint& config,
{
return ProbeStatus::BAD;
}
- return response->status >= 200 && response->status < 300
+ return response->status >= 200 && response->status < 400
? ProbeStatus::GOOD : ProbeStatus::BAD;
}
diff --git a/src/probe.h b/src/probe.h
index 4b7146b..d9a336b 100644
--- a/src/probe.h
+++ b/src/probe.h
@@ -9,7 +9,7 @@
#include "probe_status.h"
-/// HTTP configuration; only a direct 2xx response is healthy.
+/// HTTP configuration; direct 2xx and 3xx responses are healthy.
struct HttpEndpoint
{
/// HTTP or HTTPS URL, after applying any service URL fallback.
diff --git a/tests/probe_test.cpp b/tests/probe_test.cpp
index aa7ea34..d3076d5 100644
--- a/tests/probe_test.cpp
+++ b/tests/probe_test.cpp
@@ -286,7 +286,7 @@ TEST_F(ProbeTest, RefusedTcpAndHttp)
TEST_F(ProbeTest, HttpStatusCodes)
{
ASSERT_TRUE(bindServer(SOCK_STREAM, AF_INET, true));
- for(int status : {200, 204, 299, 301, 404, 503})
+ for(int status : {200, 204, 299, 300, 301, 399, 404, 503})
{
worker = std::jthread(&ProbeTest::serveHttp, this, status, false);
auto result_probe = createProbe(HttpEndpoint{
@@ -294,7 +294,7 @@ TEST_F(ProbeTest, HttpStatusCodes)
ASSERT_TRUE(result_probe) << result_probe.error().msg();
auto result = (*result_probe)->probe();
ASSERT_TRUE(result) << result.error().msg();
- EXPECT_EQ(result->status, status >= 200 && status < 300
+ EXPECT_EQ(result->status, status >= 200 && status < 400
? ProbeStatus::GOOD : ProbeStatus::BAD) << status;
worker.join();
}