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

Function read_http_headers

crates/openshell-supervisor-network/src/proxy.rs:4829–4844  ·  view source on GitHub ↗
(reader: &mut R)

Source from the content-addressed store, hash-verified

4827 }
4828
4829 async fn read_http_headers<R: TokioAsyncRead + Unpin>(reader: &mut R) -> Vec<u8> {
4830 let mut bytes = Vec::new();
4831 let mut chunk = [0u8; 256];
4832 loop {
4833 let n =
4834 tokio::time::timeout(std::time::Duration::from_secs(1), reader.read(&mut chunk))
4835 .await
4836 .expect("HTTP headers should arrive")
4837 .expect("header read should succeed");
4838 assert!(n > 0, "stream closed before HTTP headers");
4839 bytes.extend_from_slice(&chunk[..n]);
4840 if bytes.windows(4).any(|w| w == b"\r\n\r\n") {
4841 return bytes;
4842 }
4843 }
4844 }
4845
4846 fn masked_text_frame(payload: &[u8]) -> Vec<u8> {
4847 let mask = [0x11, 0x22, 0x33, 0x44];

Calls 1

readMethod · 0.45

Tested by

no test coverage detected