def add_http_headers_for_attachment(response: HttpResponse,
                                    offered_filename: str = None,
                                    content_type: str = None,
                                    as_attachment: bool = False,
                                    as_inline: bool = False,
                                    content_length: int = None) -> None:
    """
    Add HTTP headers to a Django response class object.

    Args:

        response: ``HttpResponse`` instance
        offered_filename: filename that the client browser will suggest
        content_type: HTTP content type
        as_attachment: if True, browsers will generally save to disk.
            If False, they may display it inline.
            http://www.w3.org/Protocols/rfc2616/rfc2616-sec19.html
        as_inline: attempt to force inline (only if not as_attachment)
        content_length: HTTP content length

    """
    if offered_filename is None:
        offered_filename = ''
    if content_type is None:
        content_type = 'application/force-download'
    response['Content-Type'] = content_type
    if as_attachment:
        prefix = 'attachment; '
    elif as_inline:
        prefix = 'inline; '
    else:
        prefix = ''
    fname = 'filename=%s' % smart_str(offered_filename)
    response['Content-Disposition'] = prefix + fname
    if content_length is not None:
        response['Content-Length'] = content_length
Add HTTP headers to a Django response class object.

    Args:

        response: ``HttpResponse`` instance
        offered_filename: filename that the client browser will suggest
        content_type: HTTP content type
        as_attachment: if True, browsers will generally save to disk.
            If False, they may display it inline.
            http://www.w3.org/Protocols/rfc2616/rfc2616-sec19.html
        as_inline: attempt to force inline (only if not as_attachment)
        content_length: HTTP content length