import requests


def safe_content_length(response: requests.Response) -> int:
    """Account for missing or malformed content-length data."""
    length = response.headers.get('content-length', '0')
    if not length.isdigit():
        length = '0'
    return int(length)