diff --git a/tests/unit/python/utils/docker/test_healthcheck.py b/tests/unit/python/utils/docker/test_healthcheck.py index bf60848151..bf3cd097a7 100644 --- a/tests/unit/python/utils/docker/test_healthcheck.py +++ b/tests/unit/python/utils/docker/test_healthcheck.py @@ -125,9 +125,20 @@ class TestOtherFlavors(unittest.TestCase): self.assertIn("grep -q 'HTTP/1'", argv[3]) def test_tcp_keeps_the_escapes_the_shell_needs(self): - """echo -e must receive backslash escapes, not real newlines.""" + """printf must receive backslash escapes, not real newlines.""" self.assertIn("\\r\\n", probe("tcp", port=80)[3]) + def test_the_request_stops_at_the_header_terminator(self): + """A trailing LF makes uvicorn's h11 reader answer 400, not the handler.""" + with tempfile.TemporaryDirectory() as tmp: + sent = Path(tmp) / "request" + script = f"exec 3>{sent}\n{Tcp(port=80, path='health').request()}" + subprocess.run(["bash", "-c", script], check=True) + self.assertEqual( + b"GET /health HTTP/1.1\r\nHost: localhost\r\nConnection: close\r\n\r\n", + sent.read_bytes(), + ) + def test_http_status_demands_a_2xx_or_3xx_status_line(self): argv = probe("http_status", port=80, path="health") self.assertIn("GET /health HTTP/1.1", argv[3]) diff --git a/utils/docker/healthcheck/probes.py b/utils/docker/healthcheck/probes.py index 837878bbf8..fe8c7b6c72 100644 --- a/utils/docker/healthcheck/probes.py +++ b/utils/docker/healthcheck/probes.py @@ -27,7 +27,7 @@ TIMING_DEFAULTS: dict[str, object] = { } _HTTP_REQUEST = ( - "echo -e 'GET /{path} HTTP/1.1\\r\\nHost: localhost\\r\\n" + "printf 'GET /{path} HTTP/1.1\\r\\nHost: localhost\\r\\n" "Connection: close\\r\\n\\r\\n' >&3" )