(url: str, timeout: float = 2.5)
| 325 | |
| 326 | |
| 327 | def http_health(url: str, timeout: float = 2.5) -> tuple[bool, str]: |
| 328 | try: |
| 329 | with urllib.request.urlopen(url, timeout=timeout) as response: |
| 330 | body = response.read(200).decode("utf-8", errors="replace") |
| 331 | return True, f"{response.status} {response.reason} | {body[:80]}" |
| 332 | except urllib.error.HTTPError as exc: |
| 333 | return False, f"HTTP {exc.code} {exc.reason}" |
| 334 | except Exception as exc: # noqa: BLE001 |
| 335 | return False, summarize_connection_error(str(exc)) |
| 336 | |
| 337 | |
| 338 | def is_port_open(port: int, host: str = "127.0.0.1", timeout: float = 0.8) -> bool: |
no test coverage detected