Get a filename from the Content-Disposition header, if available.

    >>> from planet.api import utils
    >>> headers = {
    ...     'date': 'Thu, 14 Feb 2019 16:13:26 GMT',
    ...     'last-modified': 'Wed, 22 Nov 2017 17:22:31 GMT',
    ...     'accept-ranges': 'bytes',
    ...     'content-type': 'image/tiff',
    ...     'content-length': '57350256',
    ...     'content-disposition': 'attachment; filename="open_california.tif"'
    ... }
    >>> name = utils.get_filename_from_headers(headers)
    >>> print(name)
    open_california.tif
    >>>
    >>> headers.pop('content-disposition', None)
    'attachment; filename="open_california.tif"'
    >>> name = utils.get_filename_from_headers(headers)
    >>> print(name)
    None
    >>>

    :param headers dict: a ``dict`` of response headers
    :returns: a filename (i.e. ``basename``)
    :rtype: str or None

def get_filename_from_headers(headers):
    """Get a filename from the Content-Disposition header, if available.

    >>> from planet.api import utils
    >>> headers = {
    ...     'date': 'Thu, 14 Feb 2019 16:13:26 GMT',
    ...     'last-modified': 'Wed, 22 Nov 2017 17:22:31 GMT',
    ...     'accept-ranges': 'bytes',
    ...     'content-type': 'image/tiff',
    ...     'content-length': '57350256',
    ...     'content-disposition': 'attachment; filename="open_california.tif"'
    ... }
    >>> name = utils.get_filename_from_headers(headers)
    >>> print(name)
    open_california.tif
    >>>
    >>> headers.pop('content-disposition', None)
    'attachment; filename="open_california.tif"'
    >>> name = utils.get_filename_from_headers(headers)
    >>> print(name)
    None
    >>>

    :param headers dict: a ``dict`` of response headers
    :returns: a filename (i.e. ``basename``)
    :rtype: str or None
    """
    cd = headers.get('content-disposition', '')
    match = re.search('filename="?([^"]+)"?', cd)
    return match.group(1) if match else None