def _close_after_stream(response, chunk_size):
    """Iterate over the content and ensure the response is closed after."""
    for chunk in response.iter_content(chunk_size=chunk_size):
        yield chunk
    response.close()
