Python hgweb原始视图返回错误的内容类型

Python hgweb原始视图返回错误的内容类型,python,mercurial,content-type,hgweb,Python,Mercurial,Content Type,Hgweb,背景:我正在使用Mercurial浏览器为我正在构建的Django站点添加浏览器 我遇到的问题是:我们存储在HG repo中的特定文件是绑定区文件,并且恰好命名为/some/path/somedomain.com,这导致hgweb在返回文件原始视图时将内容类型设置为application/x-msdos-program,而内容实际上是文本/纯文本。不正确的内容类型导致hgwebproxy将内容转储到页面模板中,而不是仅返回它。它执行如下测试以跳过模板: if response['content-

背景:我正在使用Mercurial浏览器为我正在构建的Django站点添加浏览器

我遇到的问题是:我们存储在HG repo中的特定文件是绑定区文件,并且恰好命名为/some/path/somedomain.com,这导致hgweb在返回文件原始视图时将内容类型设置为application/x-msdos-program,而内容实际上是文本/纯文本。不正确的内容类型导致hgwebproxy将内容转储到页面模板中,而不是仅返回它。它执行如下测试以跳过模板:

if response['content-type'].split(';')[0] in ('application/octet-stream', 'text/plain'):
    return response
一些可行的解决方案当然是可行的

将所有文件重命名为.zone Lame且耗时 黑客hgwebproxy传递应用程序/x-msdos-program Lame and dirty 说服hgweb使用正确的内容类型!我希望你能帮忙
hgweb使用mime类型来检测文件的mime类型。您可以通过添加设置文件来覆盖.com后缀检测。见:


谢谢我需要把它发布出去,所以我修改了/etc/mime.types。
>>> import mimetypes
>>> mimetypes.init()
>>> mimetypes.knownfiles
['/etc/mime.types', '/etc/httpd/mime.types', '/etc/httpd/conf/mime.types', '/etc/apache/mime.types', '/etc/apache2/mime.types', '/usr/local/etc/httpd/conf/mime.types', '/usr/local/lib/netscape/mime.types', '/usr/local/etc/httpd/conf/mime.types', '/usr/local/etc/mime.types']