MCPcopy Create free account
hub / github.com/NVIDIA/OpenShell / send_raw

Function send_raw

crates/openshell-supervisor-network/tests/sigv4_localstack.rs:30–55  ·  view source on GitHub ↗
(raw: &[u8])

Source from the content-addressed store, hash-verified

28}
29
30async fn send_raw(raw: &[u8]) -> (u16, String) {
31 let mut stream = TcpStream::connect(LOCALSTACK)
32 .await
33 .expect("connect to LocalStack");
34 stream.write_all(raw).await.expect("write request");
35
36 let mut buf = Vec::with_capacity(16384);
37 let mut tmp = [0u8; 4096];
38 loop {
39 match tokio::time::timeout(std::time::Duration::from_secs(5), stream.read(&mut tmp)).await {
40 Ok(Ok(0)) | Err(_) => break,
41 Ok(Ok(n)) => buf.extend_from_slice(&tmp[..n]),
42 Ok(Err(e)) => panic!("read error: {e}"),
43 }
44 }
45
46 let response = String::from_utf8_lossy(&buf).to_string();
47 let status = response
48 .lines()
49 .next()
50 .and_then(|line| line.split_whitespace().nth(1))
51 .and_then(|s| s.parse::<u16>().ok())
52 .unwrap_or(0);
53
54 (status, response)
55}
56
57async fn signed_request(raw: &str, host: &str, service: &str) -> (u16, String) {
58 let signed = apply_sigv4_to_request(

Calls 3

connectFunction · 0.85
readMethod · 0.45
nextMethod · 0.45

Tested by

no test coverage detected