Reputation: 640
Currently I'm converting a small project from node.js/express to python/falcon. In node to encode a contect-disposition header I'm using this library: https://github.com/jshttp/content-disposition
import contentDisposition from 'content-disposition';
resp.setHeader('Content-Disposition', contentDisposition(filename));
Looking for a way to do this in Python.
Upvotes: 1
Views: 726
Reputation: 640
The equivalent library is called "rfc6266" (it seems it was always on top of google search results, but due to it's name I never actually looked at the page thinking it was a standard description).
import rfc6266
resp.set_header('Content-Disposition', rfc6266.build_header(filename).decode('iso-8859-1')) # the function returns bytes
Upvotes: 1