MCPcopy Create free account
hub / github.com/FastLED/FastLED / send_request

Function send_request

examples/Asio/Server/test_client.py:75–96  ·  view source on GitHub ↗

Send HTTP GET request and measure response time.

(client: httpx.Client, url: str, config: TestConfig)

Source from the content-addressed store, hash-verified

73
74
75def send_request(client: httpx.Client, url: str, config: TestConfig) -> RequestResult:
76 """Send HTTP GET request and measure response time."""
77 try:
78 start_time = time.perf_counter()
79 response = client.get(url, timeout=config.timeout)
80 elapsed_ms = (time.perf_counter() - start_time) * 1000
81
82 return RequestResult(
83 success=response.status_code == 200,
84 status_code=response.status_code,
85 response_text=response.text.strip(),
86 response_time_ms=elapsed_ms,
87 )
88 except httpx.ConnectError:
89 return RequestResult(False, None, None, 0.0, "Connection refused")
90 except httpx.TimeoutException:
91 return RequestResult(False, None, None, 0.0, "Request timeout")
92 except KeyboardInterrupt:
93 _thread.interrupt_main()
94 raise
95 except Exception as e:
96 return RequestResult(False, None, None, 0.0, str(e))
97
98
99def run_tests(config: TestConfig) -> list[RequestResult]:

Callers 2

run_testsFunction · 0.85
test_network_exampleFunction · 0.85

Calls 2

RequestResultClass · 0.85
getMethod · 0.45

Tested by

no test coverage detected