MCPcopy Create free account
hub / github.com/awslabs/llrt / get

Method get

modules/llrt_fetch/src/headers.rs:143–166  ·  view source on GitHub ↗
(&self, ctx: Ctx<'js>, key: String)

Source from the content-addressed store, hash-verified

141 }
142
143 pub fn get<'js>(&self, ctx: Ctx<'js>, key: String) -> Result<Value<'js>> {
144 let key = lower_key(key);
145 if !is_http_header_name(&key) {
146 return Err(Exception::throw_type(&ctx, "Invalid key"));
147 }
148
149 if key.as_ref() == SET_COOKIE.as_str() {
150 let result: Vec<&str> = self
151 .headers
152 .iter()
153 .filter_map(|(k, v)| if k == &key { Some(v.as_ref()) } else { None })
154 .collect();
155 return if result.is_empty() {
156 Null.into_js(&ctx)
157 } else {
158 result.join(", ").into_js(&ctx)
159 };
160 }
161 self.headers
162 .iter()
163 .find(|(k, _)| *k == key)
164 .map(|(_, v)| v.as_ref().into_js(&ctx))
165 .unwrap_or_else(|| Null.into_js(&ctx))
166 }
167
168 pub fn get_set_cookie(&self) -> Vec<&str> {
169 self.headers

Callers 15

lambda-server.jsFile · 0.45
newMethod · 0.45
fromFunction · 0.45
get_write_parametersFunction · 0.45
set_prototypeFunction · 0.45
evaluateMethod · 0.45
evaluateMethod · 0.45
pbkdf2_derive_keyMethod · 0.45
insert_id_mapFunction · 0.45
get_id_mapFunction · 0.45

Calls 7

lower_keyFunction · 0.85
is_http_header_nameFunction · 0.85
joinMethod · 0.80
as_strMethod · 0.45
iterMethod · 0.45
is_emptyMethod · 0.45
into_jsMethod · 0.45

Tested by 7

test_response_streamFunction · 0.36
test_response_large_bodyFunction · 0.36
test_fetch_functionFunction · 0.36
test_spawnFunction · 0.36
test_spawn_shellFunction · 0.36