Changing a REST service response content-type with mod_rewrite

954 views Asked by At

To work around a IE8 compatibility issue, I would like to change the content-type of a REST service response without changing my application source code.

I'm trying to do this with a mod_rewrite rule:

RewriteCond %{HTTP_USER_AGENT} .*MSIE\s8.*
RewriteRule /app/name(.*) - [T=application/new.content.type+xml]

This rule works for static content, but not for REST service responses.

I'm using Apache 2.2.3 with JBoss 5.1.

On Apache, I've configured the RewriteRule in the httpd.conf file and in the log file see:

(3) applying pattern '/app/name(.*)' to uri '/app/name/events/service'
(4) RewriteCond: input='Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR     2.0.50727)' pattern='.*MSIE\\s8.*' => matched
(2) remember /app/name/events/service to have MIME-type 'new.content.type'
(1) pass through /app/name/events/service
(1) force filename service to have MIME-type 'new.content.type'

On JBoss, I've tried configuring the RewriteValve at the Engine and Server level, and in the log file I can see:

2014-11-19 10:56:34,442 DEBUG [org.apache.catalina.core.ContainerBase.[jboss.web].[localhost]] Rewrote /app/name/events/services as /app/name/events/services with rule pattern /app/name(.*)

The rules appear to be applied, but my REST service content-type remains the same.

Could anyone suggest a reason why, or next steps to debug this further?

Many thanks.

0

There are 0 answers