Bug 61621

Summary: Content-Type is forced to lowercase when it goes through mod_jk
Product: Tomcat Connectors Reporter: Mark O'Donohue <odoma04>
Component: mod_jkAssignee: Tomcat Developers Mailing List <dev>
Status: NEW ---    
Severity: enhancement    
Priority: P2    
Version: unspecified   
Target Milestone: ---   
Hardware: All   
OS: All   

Description Mark O'Donohue 2017-10-15 23:07:08 UTC
Running our proxied request via mod_jk we are seeing the returned content-type being changing to all lowercase: 

  Content-Type: application/xxx.yyyy.dddd+JSON; charset=utf-8
  Content-Type: application/xxx.yyyy.dddd+json; charset=utf-8

We thought this was tomcat at first, but turns out to be mod_jk.c that is the cause : 

for (h = 0; h < num_of_headers; h++) {
        if (!strcasecmp(header_names[h], "Content-type")) {
            char *tmp = apr_pstrdup(r->pool, header_values[h]);
            /* It should be done like this in Apache 2.0 */
            /* This way, Apache 2.0 will be able to set the output filter */
            /* and it make jk useable with deflate using */
            /* AddOutputFilterByType DEFLATE text/html */
            ap_set_content_type(r, tmp);

Now on the validity of upper vs lower - it seems a little bit of a grey area:

The type, subtype, and parameter names are not case sensitive. For example, TEXT, Text, and TeXt are all equivalent. Parameter values are normally case sensitive, but certain parameters are interpreted to be case- insensitive, depending on the intended use. (For example, multipart boundaries are case-sensitive, but the "access- type" for message/External-body is not case-sensitive.)
In our usage we are acting as a proxy, and as a proxy we dont have an opinion on if it should be forced to lower case or allow mixed case - we just want to pass on what we get :-) - but certainly some JkOption may be useful way to retain original behaviour but allow overwriting. 

Also if we run the request via mod_proxy/mod_proxy_ajp.c instead then the returned content-type header is not changed.
Comment 1 Mark Thomas 2017-11-22 14:15:48 UTC
It is worth noting that ap_content_type_to_lower() only changes the type and sub-type. Parameter names and values remain unchanged.

Removing this call in mod_jk breaks the use of AddOutputFilterByType.

Testing with mod_proxy confirms that it doesn't change the case of the Content-type but also demonstrates that the use of AddOutputFilterByType is broken with mod_proxy if the Content-type is not lower case.

I looked, but could not find, any bug reports against mod_proxy for AddOutputFilterByType not working.

I don't have any objections to making the mod_jk behaviour configurable although I do think that the current behaviour should remain the default. I am therefore moving this issue to an enhancement request.