MCPcopy
hub / github.com/pallets/werkzeug / _get_real_value

Method _get_real_value

src/werkzeug/middleware/proxy_fix.py:105–124  ·  view source on GitHub ↗

Get the real value from a list header based on the configured number of trusted proxies. :param trusted: Number of values to trust in the header. :param value: Comma separated list header value to parse. :return: The real value, or ``None`` if there are fewer values

(self, trusted: int, value: str | None)

Source from the content-addressed store, hash-verified

103 self.x_prefix = x_prefix
104
105 def _get_real_value(self, trusted: int, value: str | None) -> str | None:
106 """Get the real value from a list header based on the configured
107 number of trusted proxies.
108
109 :param trusted: Number of values to trust in the header.
110 :param value: Comma separated list header value to parse.
111 :return: The real value, or ``None`` if there are fewer values
112 than the number of trusted proxies.
113
114 .. versionchanged:: 1.0
115 Renamed from ``_get_trusted_comma``.
116
117 .. versionadded:: 0.15
118 """
119 if not (trusted and value):
120 return None
121 values = parse_list_header(value)
122 if len(values) >= trusted:
123 return values[-trusted]
124 return None
125
126 def __call__(
127 self, environ: WSGIEnvironment, start_response: StartResponse

Callers 1

__call__Method · 0.95

Calls 1

parse_list_headerFunction · 0.85

Tested by

no test coverage detected