Home / Function/ unquote_header_value() — requests Function Reference

unquote_header_value() — requests Function Reference

Architecture documentation for the unquote_header_value() function in utils.py from the requests codebase.

Entity Profile

Dependency Diagram

graph TD
  afbe85d3_dee9_493b_5414_1e453dcc99d2["unquote_header_value()"]
  2c39b9da_e317_5e6c_bbac_8362bac2110c["utils.py"]
  afbe85d3_dee9_493b_5414_1e453dcc99d2 -->|defined in| 2c39b9da_e317_5e6c_bbac_8362bac2110c
  9a9988d6_bd3b_3f66_965e_2ff796ea8395["parse_list_header()"]
  9a9988d6_bd3b_3f66_965e_2ff796ea8395 -->|calls| afbe85d3_dee9_493b_5414_1e453dcc99d2
  85f754cb_6190_2351_34cb_47f7d725e66b["parse_dict_header()"]
  85f754cb_6190_2351_34cb_47f7d725e66b -->|calls| afbe85d3_dee9_493b_5414_1e453dcc99d2
  style afbe85d3_dee9_493b_5414_1e453dcc99d2 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

src/requests/utils.py lines 430–452

def unquote_header_value(value, is_filename=False):
    r"""Unquotes a header value.  (Reversal of :func:`quote_header_value`).
    This does not use the real unquoting but what browsers are actually
    using for quoting.

    :param value: the header value to unquote.
    :rtype: str
    """
    if value and value[0] == value[-1] == '"':
        # this is not the real unquoting, but fixing this so that the
        # RFC is met will result in bugs with internet explorer and
        # probably some other browsers as well.  IE for example is
        # uploading files with "C:\foo\bar.txt" as filename
        value = value[1:-1]

        # if this is a filename and the starting characters look like
        # a UNC path, then just return the value without quotes.  Using the
        # replace sequence below on a UNC path has the effect of turning
        # the leading double slash into a single slash and then
        # _fix_ie_filename() doesn't work correctly.  See #458.
        if not is_filename or value[:2] != "\\\\":
            return value.replace("\\\\", "\\").replace('\\"', '"')
    return value

Domain

Subdomains

Frequently Asked Questions

What does unquote_header_value() do?
unquote_header_value() is a function in the requests codebase, defined in src/requests/utils.py.
Where is unquote_header_value() defined?
unquote_header_value() is defined in src/requests/utils.py at line 430.
What calls unquote_header_value()?
unquote_header_value() is called by 2 function(s): parse_dict_header, parse_list_header.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free