MCPcopy
hub / github.com/benoitc/gunicorn / _normalize_sockaddr

Function _normalize_sockaddr

gunicorn/asgi/protocol.py:41–48  ·  view source on GitHub ↗

Normalize socket address to ASGI-compatible (host, port) tuple. ASGI spec requires server/client to be (host, port) tuples. IPv6 sockets return 4-tuples (host, port, flowinfo, scope_id), so we extract just the first two elements.

(sockaddr)

Source from the content-addressed store, hash-verified

39
40
41def _normalize_sockaddr(sockaddr):
42 """Normalize socket address to ASGI-compatible (host, port) tuple.
43
44 ASGI spec requires server/client to be (host, port) tuples.
45 IPv6 sockets return 4-tuples (host, port, flowinfo, scope_id),
46 so we extract just the first two elements.
47 """
48 return tuple(sockaddr[:2]) if sockaddr else None
49
50
51def _check_trusted_proxy(peer_addr, allow_list, networks):

Calls

no outgoing calls