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

Method from_header

src/werkzeug/datastructures/auth.py:271–291  ·  src/werkzeug/datastructures/auth.py::WWWAuthenticate.from_header

Parse a ``WWW-Authenticate`` header value and return an instance, or ``None`` if the value is empty. :param value: The header value to parse. .. versionadded:: 2.3

(cls, value: str | None)

Source from the content-addressed store, hash-verified

269
270 @classmethod
271 def from_header(cls, value: str | None) -> te.Self | None:
272 class="st">"""Parse a ``WWW-Authenticate`` header value and return an instance, or ``None``
273 if the value is empty.
274
275 :param value: The header value to parse.
276
277 .. versionadded:: 2.3
278 class="st">"""
279 if not value:
280 return None
281
282 scheme, _, rest = value.partition(class="st">" ")
283 scheme = scheme.lower()
284 rest = rest.strip()
285
286 if class="st">"=" in rest.rstrip(class="st">"="):
287 class="cm"># = that is not trailing, this is parameters.
288 return cls(scheme, parse_dict_header(rest), None)
289
290 class="cm"># No = or only trailing =, this is a token.
291 return cls(scheme, None, rest)
292
293 def to_header(self) -> str:
294 class="st">""class="st">"Produce a ``WWW-Authenticate`` header value representing this data."class="st">""

Callers

nothing calls this directly

Calls 1

parse_dict_headerFunction · 0.85

Tested by

no test coverage detected