【发布时间】:2012-09-11 17:59:23
【问题描述】:
我使用 libmagic 在我的项目的 Web 界面中获取文件的 mime 类型。我在 css 和 js 文件上获得 text/plain mime 类型。
例如 chromium 显示以下警告:
Resource interpreted as Stylesheet but transferred with MIME type text/plain: "http://localhost:8000/jquery-ui.css".
Resource interpreted as Script but transferred with MIME type text/plain: "http://localhost:8000/jquery.timers.js".
Http 对话框
alex@alex-laptop ~ $ nc localhost 8000
GET /ui.css HTTP/1.1
HTTP/1.1 200 OK
Connection: close
Content-Length: 699
Content-Type: text/plain; charset=us-ascii
Date: Wed, 19 Sep 2012 11:41:48 GMT
...
我该如何解决这个问题?
【问题讨论】:
-
为什么你为此使用 libmagic? .css 和 .js 的 mime 类型定义明确,您无需猜测它们(这几乎就是 libmagic 所做的)。
-
我使用了很多不同类型的文件。我不想硬编码他们的 mime 类型。
标签: javascript css c libmagic