users@jersey.java.net

[Jersey] Re: Client Request/Response Filters for authentication

From: Maarten Boekhold <boekhold_at_gmx.com>
Date: Mon, 02 Mar 2015 12:31:51 +0400

Ah, wish I could take the below mail back.... I see it now.

response.getHeaders() doesn't return a copy, it returns the actual
headers map, so this code deletes the original (non-authenticated)
response headers and replaces them with the headers from the repeated
(authenticated) response.

Maarten

On 2015-03-02 12:15, Maarten Boekhold wrote:
> Hi,
>
> I'm looking into writing a custom Request/Response Filter to handle an
> internal request authentication method, and I'm studying the Jersey
> HttpAuthenticationFilter for that.
>
> I'm looking at the source, and in the "repeatRequest" method there is
> a few lines of code that I don't understand the purpose of:
>
> MultivaluedMap<String, String> headers = response.getHeaders();
> headers.clear();
> headers.putAll(nextResponse.getStringHeaders());
>
> I might be blind, but I don't see what this is supposed to accomplish.
> As far as I can see, this is dead code. "headers" is not used in the
> remainder of the method...
>
> So, please tell me, am I blind? :)
>
> Maarten