MCPcopy Create free account
hub / github.com/vercel/vercel / get_header

Function get_header

python/vercel-runtime/src/vercel_runtime/asgi.py:17–36  ·  view source on GitHub ↗
(scope: dict[str, Any], name: str)

Source from the content-addressed store, hash-verified

15
16
17def get_header(scope: dict[str, Any], name: str) -> str | None:
18 headers_object = scope.get("headers")
19 if headers_object is None:
20 return None
21
22 headers = cast("list[tuple[object, object]]", headers_object)
23 target = name.lower().encode("latin1")
24 try:
25 for key, value in headers:
26 is_match = (
27 isinstance(key, (bytes, bytearray))
28 and bytes(key).lower() == target
29 )
30 if is_match:
31 if isinstance(value, (bytes, bytearray)):
32 return bytes(value).decode("latin1")
33 return str(value)
34 except Exception:
35 return None
36 return None
37
38
39async def drain_body(

Callers 1

appFunction · 0.90

Calls 4

lowerMethod · 0.80
decodeMethod · 0.80
getMethod · 0.65
encodeMethod · 0.45

Tested by

no test coverage detected