MCPcopy Create free account
hub / github.com/StarsTom/mobileCodexHelper / http_health

Function http_health

mobile_codex_control.py:327–335  ·  view source on GitHub ↗
(url: str, timeout: float = 2.5)

Source from the content-addressed store, hash-verified

325
326
327def 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
338def is_port_open(port: int, host: str = "127.0.0.1", timeout: float = 0.8) -> bool:

Callers 4

build_remote_statusFunction · 0.85
collect_statusFunction · 0.85
stack_is_runningFunction · 0.85
stack_is_stoppedFunction · 0.85

Calls 1

Tested by

no test coverage detected