atom feed16 messages in net.java.dev.jersey.usersRe: [Jersey] modifying jersey client ...
FromSent OnAttachments
Zoltan Arnold NAGYOct 7, 2009 8:05 am 
Felipe GauchoOct 7, 2009 8:36 am 
Paul SandozOct 7, 2009 8:46 am 
Zoltan Arnold NAGYOct 8, 2009 1:34 pm 
Craig McClanahanOct 8, 2009 2:55 pm 
Zoltan Arnold NAGYOct 9, 2009 1:13 am 
Paul SandozOct 9, 2009 1:18 am 
Zoltan Arnold NAGYOct 9, 2009 1:27 am 
Paul SandozOct 9, 2009 1:40 am 
Zoltan Arnold NAGYOct 13, 2009 7:30 am 
Paul SandozOct 13, 2009 10:52 am 
Zoltan Arnold NAGYOct 13, 2009 2:08 pm 
Paul SandozOct 14, 2009 1:58 am 
Zoltan Arnold NAGYOct 14, 2009 5:37 am 
Paul SandozOct 14, 2009 5:46 am 
Zoltan Arnold NAGYOct 14, 2009 5:55 am 
Subject:Re: [Jersey] modifying jersey client requests
From:Paul Sandoz (Paul@Sun.COM)
Date:Oct 14, 2009 1:58:17 am
List:net.java.dev.jersey.users

On Oct 13, 2009, at 11:08 PM, Zoltan Arnold NAGY wrote:

and in HasingOutputStream: // baos holds the copy of the stream

@Override public void close() throws IOException { String auth = "xy"; List<Object> x = new ArrayList<Object>(); x.add(auth); request.getHeaders().put("Authorization", x);

baos.close(); out.close(); }

right?

Did you verify that the close method gets called?

In the write methods of HasingOutputStream are you also writing to "out"? If so then the request headers will have already been written by the time close has been called so the addition of headers at that point will not make any difference.

You are also not writing out the buffered copy, "baos", on close. The implementation should adapt the writes to write to the buffered copy and then on close calculate new headers and write out the buffered copy to "out".

the code snippet above was a simplified version, not a correct one. check the link below for a correct snippet.

but let me say that this is very confusing. If I understand correctly, I can only alter the bytestream representation of the entity in the adapt() method, after serialization, but when that gets called, the headers are already sent, but it seems that's the only place where I can actually inpsect the generated bytecode.

I don't see how I could possibly alter the headers from the adapt() method.

As long as you do not write to the to the OutputStream that is passed in to the adapt method you can add headers. Once one or more bytes are written to that stream the request is committed (headers are written).

currently I'm trying this approach, and server side logging indicates that the added header never arrives.

Perhaps you can send the complete code?

Sure. Code is here: http://nagyz.pastebin.com/m1e237267

That looks good. At line 42 it should be possible to add headers. If you cannot it is a bug. Can you verify when the client performs a POST request that the AuthFilter.close() is called?

Paul.