users@jersey.java.net

Re: [Jersey] modifying jersey client requests

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Fri, 09 Oct 2009 10:18:55 +0200

On Oct 9, 2009, at 10:13 AM, Zoltan Arnold NAGY wrote:

> Zoltan Arnold NAGY wrote:
>> Paul Sandoz wrote:
>>>
>>> On Oct 7, 2009, at 5:36 PM, Felipe Gaucho wrote:
>>>
>>>> A filter?
>>>>
>>>
>>> Yes, see ClientFilter and the source code for the LoggingFilter
>>> (see below because java.net is so damn slow).
>>>
>>> You need to return an output stream in the implementation of
>>> AbstractClientRequestAdapter .adapt that buffers the bytes then on
>>> the close calculates the hash, sets the header and writes out the
>>> bytes of the buffered output stream to the actual output stream.
>> Thanks, it seems to be working. :)
> Spoken too soon.
> In the message to be hashed I need to add the method, the date, and
> other data as well.
>
> It seems to me that if I do a simple .get() (no entity present) and
> I do attach an adapter with
> request.setAdapter(new Adapter(request.getAdapter(), b));
> then it's adapt() method wont even get called (at least I've put
> logging there, and never saw
> it's output).
>
> In all the examples I've seen one only attaches such an adapter if
> there's an entity present, so
> I'm thinking that maybe these request adaptert are only used to
> modify the entity's serialized form?
>

Yes, because it is adapting a *request* entity. If there is no request
entity present then no adaption will occur because there is nothing to
adapt.

Do you want to hash a request entity or a response entity?

Paul.