Add a new header tuple to the list. Keyword arguments can specify additional parameters for the header value, with underscores converted to dashes:: >>> d = Headers() >>> d.add('Content-Type', 'text/plain') >>> d.add('Content-Disposition', 'attachment', file
(self, key: str, value: t.Any, /, **kwargs: t.Any)
| 339 | return len(self._list) |
| 340 | |
| 341 | def add(self, key: str, value: t.Any, /, **kwargs: t.Any) -> None: |
| 342 | """Add a new header tuple to the list. |
| 343 | |
| 344 | Keyword arguments can specify additional parameters for the header |
| 345 | value, with underscores converted to dashes:: |
| 346 | |
| 347 | >>> d = Headers() |
| 348 | >>> d.add('Content-Type', 'text/plain') |
| 349 | >>> d.add('Content-Disposition', 'attachment', filename='foo.png') |
| 350 | |
| 351 | The keyword argument dumping uses :func:`dump_options_header` |
| 352 | behind the scenes. |
| 353 | |
| 354 | .. versionchanged:: 0.4.1 |
| 355 | keyword arguments were added for :mod:`wsgiref` compatibility. |
| 356 | """ |
| 357 | if kwargs: |
| 358 | value = _options_header_vkw(value, kwargs) |
| 359 | |
| 360 | value_str = _str_header_value(value) |
| 361 | self._list.append((key, value_str)) |
| 362 | |
| 363 | def add_header(self, key: str, value: t.Any, /, **kwargs: t.Any) -> None: |
| 364 | """Add a new header tuple to the list. |