MCPcopy Create free account
hub / github.com/bytecodealliance/wstd / http_timeout

Function http_timeout

tests/http_timeout.rs:6–23  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

4
5#[wstd::test]
6async fn http_timeout() -> Result<(), Box<dyn std::error::Error>> {
7 // This get request will connect to the server, which will then wait 1 second before
8 // returning a response.
9 let request = Request::get("https://postman-echo.com/delay/1").body(Body::empty())?;
10 let result = Client::new()
11 .send(request)
12 .timeout(Duration::from_millis(500))
13 .await;
14
15 assert!(result.is_err(), "response should be an error");
16 let error = result.unwrap_err();
17 assert!(
18 matches!(error.kind(), std::io::ErrorKind::TimedOut),
19 "expected TimedOut error, got: {error:?>}"
20 );
21
22 Ok(())
23}

Callers

nothing calls this directly

Calls 4

getFunction · 0.85
emptyFunction · 0.85
timeoutMethod · 0.80
sendMethod · 0.45

Tested by

no test coverage detected