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

Method add

src/werkzeug/datastructures/headers.py:341–361  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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.

Callers 8

extendMethod · 0.95
add_headerMethod · 0.95
setlistMethod · 0.95
createConsoleFunction · 0.45
createConsoleOutputFunction · 0.45
add_fileMethod · 0.45

Calls 3

_options_header_vkwFunction · 0.85
_str_header_valueFunction · 0.85
appendMethod · 0.80