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)
| 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">"" |
nothing calls this directly
no test coverage detected