users@jersey.java.net

[Jersey] ClientResponseFilter not executed when response is a redirect

From: Will Ferguson <willferguson00_at_gmail.com>
Date: Thu, 5 Jun 2014 15:19:20 +0100

Hi All,

I'm trying to modify request headers when my client receives a 3xx
redirect.

The server I'm talking to requires the "Authorization" header, but
sometimes I get a redirect to Amazon S3 which then returns a 400 because
the Authorization header is illegal. So, I'm wanting to remove this header
if the redirect is to an S3 URL.

The problem I have is that if I have FOLLOW_REDIRECTS as true, then the
filter doesn't get executed. It does get executed if I disable redirects,
but the redirection to S3 rarely happens and I'd rather not handle the
redirects myself.

Is this intended behaviour and could anyone recommend a better /
alternative solution. I was previously (Jersey 2.4) using the HttpClient
redirectStrategy, but now we've upgraded to 2.9 this is no longer possible.

Thanks in advance,

Will