parse_dict_header() — requests Function Reference
Architecture documentation for the parse_dict_header() function in utils.py from the requests codebase.
Entity Profile
Dependency Diagram
graph TD 85f754cb_6190_2351_34cb_47f7d725e66b["parse_dict_header()"] 2c39b9da_e317_5e6c_bbac_8362bac2110c["utils.py"] 85f754cb_6190_2351_34cb_47f7d725e66b -->|defined in| 2c39b9da_e317_5e6c_bbac_8362bac2110c 351a1e00_cb4e_af8e_1ed9_e33664efe05e["handle_401()"] 351a1e00_cb4e_af8e_1ed9_e33664efe05e -->|calls| 85f754cb_6190_2351_34cb_47f7d725e66b 342c3122_113c_32a4_2286_94935f7ac0a8["items()"] 85f754cb_6190_2351_34cb_47f7d725e66b -->|calls| 342c3122_113c_32a4_2286_94935f7ac0a8 afbe85d3_dee9_493b_5414_1e453dcc99d2["unquote_header_value()"] 85f754cb_6190_2351_34cb_47f7d725e66b -->|calls| afbe85d3_dee9_493b_5414_1e453dcc99d2 style 85f754cb_6190_2351_34cb_47f7d725e66b fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
src/requests/utils.py lines 395–426
def parse_dict_header(value):
"""Parse lists of key, value pairs as described by RFC 2068 Section 2 and
convert them into a python dict:
>>> d = parse_dict_header('foo="is a fish", bar="as well"')
>>> type(d) is dict
True
>>> sorted(d.items())
[('bar', 'as well'), ('foo', 'is a fish')]
If there is no value for a key it will be `None`:
>>> parse_dict_header('key_without_value')
{'key_without_value': None}
To create a header from the :class:`dict` again, use the
:func:`dump_header` function.
:param value: a string with a dict header.
:return: :class:`dict`
:rtype: dict
"""
result = {}
for item in _parse_list_header(value):
if "=" not in item:
result[item] = None
continue
name, value = item.split("=", 1)
if value[:1] == value[-1:] == '"':
value = unquote_header_value(value[1:-1])
result[name] = value
return result
Domain
Subdomains
Defined In
Called By
Source
Frequently Asked Questions
What does parse_dict_header() do?
parse_dict_header() is a function in the requests codebase, defined in src/requests/utils.py.
Where is parse_dict_header() defined?
parse_dict_header() is defined in src/requests/utils.py at line 395.
What does parse_dict_header() call?
parse_dict_header() calls 2 function(s): items, unquote_header_value.
What calls parse_dict_header()?
parse_dict_header() is called by 1 function(s): handle_401.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free