You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Guy Pardon <gu...@atomikos.com> on 2012/01/15 17:01:03 UTC

REST WebClient: how to inspect and set eTag headers?

Hi,

I want to inspect eTag headers in responses from a REST service, to set them on later PUT requests. Any guidelines on how to do this with the CXF WebClient API? 

Thanks
Guy

Re: REST WebClient: how to inspect and set eTag headers?

Posted by Guy Pardon <gu...@mac.com>.
Brilliant, thanks!

Sent from my iPhone

On 16 Jan 2012, at 13:34, Sergey Beryozkin <sb...@gmail.com> wrote:

> Hi Guy
> 
> On 15/01/12 16:01, Guy Pardon wrote:
>> Hi,
>> 
>> I want to inspect eTag headers in responses from a REST service, to set them on later PUT requests. Any guidelines on how to do this with the CXF WebClient API?
> 
> You can do something like this:
> 
> Book book = webClient.get(Book.class);
> Object header = webClient.getResponse().getMetadata().getFirst("ETag");
> if (header != null) {
>   EntityTag eTag = EntityTag.fromString(header);
>   ...
> }
> 
> In JAX-RS 2.0 it will be easier to deal with Response headers.
> 
> and then
> 
> webClient.header("If-None-Match", eTag);
> etc...
> 
> Cheers, Sergey
> 
> 
>> 
>> Thanks
>> Guy

Re: REST WebClient: how to inspect and set eTag headers?

Posted by Sergey Beryozkin <sb...@gmail.com>.
Hi Guy

On 15/01/12 16:01, Guy Pardon wrote:
> Hi,
>
> I want to inspect eTag headers in responses from a REST service, to set them on later PUT requests. Any guidelines on how to do this with the CXF WebClient API?

You can do something like this:

Book book = webClient.get(Book.class);
Object header = webClient.getResponse().getMetadata().getFirst("ETag");
if (header != null) {
    EntityTag eTag = EntityTag.fromString(header);
    ...
}

In JAX-RS 2.0 it will be easier to deal with Response headers.

and then

webClient.header("If-None-Match", eTag);
etc...

Cheers, Sergey


>
> Thanks
> Guy