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

Function main

tests/http_get_json.rs:11–29  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

9
10#[wstd::test]
11async fn main() -> Result<(), Box<dyn Error>> {
12 let request = Request::get("https://postman-echo.com/get").body(Body::empty())?;
13
14 let response = Client::new().send(request).await?;
15
16 let content_type = response
17 .headers()
18 .get("Content-Type")
19 .ok_or("response expected to have Content-Type header")?;
20 assert_eq!(content_type, "application/json; charset=utf-8");
21
22 let Echo { url } = response.into_body().json::<Echo>().await?;
23 assert!(
24 url.contains("postman-echo.com/get"),
25 "expected body url to contain the authority and path, got: {url}"
26 );
27
28 Ok(())
29}

Callers

nothing calls this directly

Calls 3

getFunction · 0.85
emptyFunction · 0.85
sendMethod · 0.45

Tested by

no test coverage detected