def parse_fname_from_headers(headers):
    """Infers file name from HTTP Response headers"""

    # Currently, headers are provided by the requests library and are stored
    # in its CaseInsensitiveDict. In future, care is needed if a different
    # library is used that doesn't normalize casing.
    fname = headers.get('content-disposition', None)

    if fname:
        fname = fname.partition('filename=')[2]

        # Discard optional quotes in Content-Disposition file name
        if '"' == fname[0] == fname[-1]:
            fname = fname[1:-1]

    return fname