How to preserve the Content-Type header of a Tomcat HTTP response sent through an AJP connector to Apache using mod_proxy

穿精又带淫゛_ 提交于 2019-11-30 14:21:50
# DefaultType: the default MIME type the server will use for a document
# if it cannot otherwise determine one, such as from filename extensions.
# If your server contains mostly text or HTML documents, "text/plain" is
# a good value.  If most of your content is binary, such as applications
# or images, you may want to use "application/octet-stream" instead to
# keep browsers from trying to display binary files as though they are
# text.
#
DefaultType None

This is the solution. Look at this part in the httpd.conf, It's important that DefalutType is None. If you see plain/text this is the problem. Sorry, this solution is not mine but i dont find out in which blog i've found it :-)

I've spent the past two days at work tracking down something similar to this.

There have been a few bugs producing problems similar to this in the past, in both Apache HTTPD and Tomcat, but most seem to have been resolved at least 2 years ago. I think this one is what anyone using current software is likely to be hitting - it is certainly what I am currently experiencing:

https://issues.apache.org/bugzilla/show_bug.cgi?id=49929

There may be a patch in Tomcat 7.x, but nobody has tested it yet. I plan to do so when I have time in about a week as well as produce a reliable test case so this can get fixed in all relevant versions of tomcat.

This only occurs when using APR, so one intermediate solution is to avoid that (but that could have performance consequences).

This solved a head ache for me. I had Apache 2.2 as frontend with mod_proxy_ajp and jboss as backend. Several transactions failed with

Message: Client found response content type of 'text/plain; charset=UTF-8', but expected 'text/xml'.

My Apache did have 'text/plain' as DefaultType. I did not however, change this at the global level (httpd.conf). I went about and added a new line to my vhost config in the <proxy> config section setting it to text/xml.

DefaultType text/xml

I did try using None did not work for me, then I just got:

'' in the error msg instead of 'text/plain'.
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!