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

Function parse_set_header

src/werkzeug/http.py:777–807  ·  view source on GitHub ↗

Parse a set-like header and return a :class:`~werkzeug.datastructures.HeaderSet` object: >>> hs = parse_set_header('token, "quoted value"') The return value is an object that treats the items case-insensitively and keeps the order of the items: >>> 'TOKEN' in hs True >

(
    value: str | None,
    on_update: t.Callable[[ds.HeaderSet], None] | None = None,
)

Source from the content-addressed store, hash-verified

775
776
777def parse_set_header(
778 value: str | None,
779 on_update: t.Callable[[ds.HeaderSet], None] | None = None,
780) -> ds.HeaderSet:
781 """Parse a set-like header and return a
782 :class:`~werkzeug.datastructures.HeaderSet` object:
783
784 >>> hs = parse_set_header('token, "quoted value"')
785
786 The return value is an object that treats the items case-insensitively
787 and keeps the order of the items:
788
789 >>> 'TOKEN' in hs
790 True
791 >>> hs.index('quoted value')
792 1
793 >>> hs
794 HeaderSet(['token', 'quoted value'])
795
796 To create a header from the :class:`HeaderSet` again, use the
797 :func:`dump_header` function.
798
799 :param value: a set header to be parsed.
800 :param on_update: an optional callable that is called every time a
801 value on the :class:`~werkzeug.datastructures.HeaderSet`
802 object is changed.
803 :return: a :class:`~werkzeug.datastructures.HeaderSet`
804 """
805 if not value:
806 return ds.HeaderSet(None, on_update)
807 return ds.HeaderSet(parse_list_header(value), on_update)
808
809
810def parse_if_range_header(value: str | None) -> ds.IfRange:

Callers 4

make_environMethod · 0.85
get_content_lengthFunction · 0.85
fgetFunction · 0.85
pragmaMethod · 0.85

Calls 1

parse_list_headerFunction · 0.85

Tested by

no test coverage detected