Parse Forwarded For • AI Agent SDK
parse_forwarded_for: Parse an “X-Forwarded-For“ header into an ordered list of hops.
parse_forwarded_for
Function
</div>
This function is defined in the protocols module.
Parse an `X-Forwarded-For` header into an ordered list of hops.
The chain is left→right, client-first: `client, proxy1, proxy2. Empty tokens and surrounding whitespace are dropped; None`/empty yields an empty list. Pure string handling — no name resolution, no validation of whether each token is a real IP (that is the caller’s trust decision).
Signature
def parse_forwarded_for(header: Optional[str]) -> 'List[str]'Parameters
ParamField
Optional[str]No description available.
Returns
ResponseField
'List[str]'The result of the operation.
Source
View on GitHubpraisonaiagents/gateway/protocols.py at line 2620