'Returns the content length if available or `None` otherwise.'

def calculate_content_length(self):

    try:
        self._ensure_sequence()
    except RuntimeError:
        return None
    return sum((len(x) for x in self.iter_encoded()))
