问题原文
原帖链接 · Arpit Agrawal · CC BY-SA 3.0
We have just migrated from Apache 2.0.53 to Apache 2.4 Everything works perfectly for html/js/css files etc.
But we have a number of endpoints on our servers which return plain text. For example - an endpoint would return -
RIL~Reliance Industries~1234~abcd
By default the response for these do not contain any "content-type" but I am expecting "text/plain"
In Apache 2.0.53 we were using
DefaultType text/plain
But in Apache 2.4 , this directive is disabled. (Ref:http://httpd.apache.org/docs/2.4/mod/core.html#defaulttype)
I have a large number of requests and want a generic solution that I can apply to my apache so that if there is no content-type provided, then it should send "text/plain"
Any suggestions please.
社区高分解答
原帖链接 · Nitrodist · CC BY-SA 3.0
One solution is to use ForceType text/plain to set the Content-Type header to text/plain. This will make all responses return text/plain, however.
A very specific problem in using ForceType is that it breaks mod_mime's file extension detection. For example, files requested with .css or .js extensions won't have their Content-Type set to text/css or application/javascript and will instead have it set to text/plain: probably not what you want.
As noted in a chain on the apache mailing list, the reason why DefaultType was removed is because they are now recommending that the browser do the sniffing to figure out the content-type. If you're upgrading from apache 2.2 to 2.4, then you should try to just use it without adding it back in.
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
