get_encoding_from_headers() — requests Function Reference
Architecture documentation for the get_encoding_from_headers() function in utils.py from the requests codebase.
Entity Profile
Dependency Diagram
graph TD 9ab5b77a_1e93_5426_2b6e_540e378c20b4["get_encoding_from_headers()"] 2c39b9da_e317_5e6c_bbac_8362bac2110c["utils.py"] 9ab5b77a_1e93_5426_2b6e_540e378c20b4 -->|defined in| 2c39b9da_e317_5e6c_bbac_8362bac2110c 7086c4f7_aa89_192d_ccbb_8bfa981ed237["build_response()"] 7086c4f7_aa89_192d_ccbb_8bfa981ed237 -->|calls| 9ab5b77a_1e93_5426_2b6e_540e378c20b4 14580864_b859_b8af_2bd9_9a8f13e57a3d["get_unicode_from_response()"] 14580864_b859_b8af_2bd9_9a8f13e57a3d -->|calls| 9ab5b77a_1e93_5426_2b6e_540e378c20b4 3e36ad14_0ff8_5ae4_5075_977b4fa6bc08["_parse_content_type_header()"] 9ab5b77a_1e93_5426_2b6e_540e378c20b4 -->|calls| 3e36ad14_0ff8_5ae4_5075_977b4fa6bc08 3429da06_bfa7_f55e_ca34_e7199d2cf1df["get()"] 9ab5b77a_1e93_5426_2b6e_540e378c20b4 -->|calls| 3429da06_bfa7_f55e_ca34_e7199d2cf1df style 9ab5b77a_1e93_5426_2b6e_540e378c20b4 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
src/requests/utils.py lines 527–549
def get_encoding_from_headers(headers):
"""Returns encodings from given HTTP Header Dict.
:param headers: dictionary to extract encoding from.
:rtype: str
"""
content_type = headers.get("content-type")
if not content_type:
return None
content_type, params = _parse_content_type_header(content_type)
if "charset" in params:
return params["charset"].strip("'\"")
if "text" in content_type:
return "ISO-8859-1"
if "application/json" in content_type:
# Assume UTF-8 based on RFC 4627: https://www.ietf.org/rfc/rfc4627.txt since the charset was unset
return "utf-8"
Domain
Subdomains
Defined In
Source
Frequently Asked Questions
What does get_encoding_from_headers() do?
get_encoding_from_headers() is a function in the requests codebase, defined in src/requests/utils.py.
Where is get_encoding_from_headers() defined?
get_encoding_from_headers() is defined in src/requests/utils.py at line 527.
What does get_encoding_from_headers() call?
get_encoding_from_headers() calls 2 function(s): _parse_content_type_header, get.
What calls get_encoding_from_headers()?
get_encoding_from_headers() is called by 2 function(s): build_response, get_unicode_from_response.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free