werkzeug.HeaderSet

class werkzeug.HeaderSet(headers=None, on_update=None)[source]

Similar to the ETags class this implements a set-like structure. Unlike ETags this is case insensitive and used for vary, allow, and content-language headers.

If not constructed using the parse_set_header() function the instantiation works like this:

>>> hs = HeaderSet(['foo', 'bar', 'baz'])
>>> hs
HeaderSet(['foo', 'bar', 'baz'])

Methods

__init__([headers, on_update])
add(header) Add a new header to the set.
as_set([preserve_casing]) Return the set as real python set type.
clear() Clear the set.
discard(header) Like remove() but ignores errors.
find(header) Return the index of the header in the set or return -1 if not found.
index(header) Return the index of the header in the set or raise an IndexError.
remove(header) Remove a header from the set.
to_header() Convert the header set into an HTTP header string.
update(iterable) Add all the headers from the iterable to the set.