i'm working on a configuration of uwsgi+nginx for our python web app. I want to add the X-Sendfile emulation (see http://uwsgi-docs.readthedocs.io/en/latest/Snippets.html):
[uwsgi]
collect-header = X-Sendfile X_SENDFILE
response-route-if-not = empty:${X_SENDFILE} static:${X_SENDFILE}
Now i visit our site, the content is correctly responsed using sendfile(). The only flaw is Content-Type is missing, even i have set it explicitly in wsgi's response. I've experimented many methods, the only workaround i've found is:
[uwsgi]
collect-header = X-Sendfile-Content-Type X_SENDFILE_CONTENT_TYPE
collect-header = X-Sendfile X_SENDFILE
response-route-if-not= empty:${X_SENDFILE_CONTENT_TYPE} addheader:Content-Type: ${X_SENDFILE_CONTENT_TYPE}
response-route-if-not = empty:${X_SENDFILE} static:${X_SENDFILE}
This works but a little bit silly. I'd really want the content type can be determined by the file's extension. Is it possible?