Return the first value for the key if it is in the headers, otherwise set the header to the value given by ``default`` and return that. :param key: The header key to get. :param default: The value to set for the key if it is not in the headers.
(self, key: str, default: t.Any)
| 430 | self.remove(key) |
| 431 | |
| 432 | def setdefault(self, key: str, default: t.Any) -> str: |
| 433 | """Return the first value for the key if it is in the headers, |
| 434 | otherwise set the header to the value given by ``default`` and |
| 435 | return that. |
| 436 | |
| 437 | :param key: The header key to get. |
| 438 | :param default: The value to set for the key if it is not in the |
| 439 | headers. |
| 440 | """ |
| 441 | try: |
| 442 | return self._get_key(key) |
| 443 | except KeyError: |
| 444 | pass |
| 445 | |
| 446 | self.set(key, default) |
| 447 | return self._get_key(key) |
| 448 | |
| 449 | def setlistdefault(self, key: str, default: cabc.Iterable[t.Any]) -> list[str]: |
| 450 | """Return the list of values for the key if it is in the |
no test coverage detected