MCPcopy Index your code
hub / github.com/aiscriptdev/aiscript / parse_headers

Function parse_headers

aiscript-vm/src/stdlib/http.rs:34–49  ·  view source on GitHub ↗
(
    headers: HashMap<InternedString, Value, BuildHasherDefault<AHasher>>,
)

Source from the content-addressed store, hash-verified

32}
33
34fn parse_headers(
35 headers: HashMap<InternedString, Value, BuildHasherDefault<AHasher>>,
36) -> HeaderMap {
37 let mut header_map = HeaderMap::new();
38 for (key, value) in headers {
39 if let Value::String(s) = value {
40 if let (Ok(name), Ok(val)) = (
41 HeaderName::from_bytes(key.as_bytes()),
42 HeaderValue::from_bytes(s.as_bytes()),
43 ) {
44 header_map.insert(name, val);
45 }
46 }
47 }
48 header_map
49}
50
51async fn response_to_object(
52 ctx: Context<'_>,

Callers 6

http_getFunction · 0.85
http_postFunction · 0.85
http_putFunction · 0.85
http_deleteFunction · 0.85
http_patchFunction · 0.85
http_headFunction · 0.85

Calls 1

as_bytesMethod · 0.80

Tested by

no test coverage detected