Skip to main content

content_disposition_header

Construct a Content-Disposition HTTP header value from the given filename as specified by RFC 6266.

def content_disposition_header(
as_attachment: boolean,
filename: string
) - > string

Construct a Content-Disposition HTTP header value from the given filename as specified by RFC 6266.

Parameters

NameTypeDescription
as_attachmentbooleanA flag indicating whether the content should be treated as an attachment (download) or displayed inline.
filenamestringThe name of the file to be suggested in the header, which will be encoded according to RFC standards based on its character set.

Returns

TypeDescription
stringThe formatted Content-Disposition header value, or None if no filename is provided and it is not an attachment.