You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by "Barkley, Christopher" <Ch...@DISNEY.COM> on 2011/07/20 03:20:00 UTC

Is there a bug in ResponseBuilder's handling of ETags?

I'm working with cxf-rt-frontend-jaxrs 2.4.1...

The ResponseBuilder interface defines two versions of the tag() method, one that takes a String and one that takes an EntityTag.  The Javadocs say that the String version "is a shortcut for tag(new EntityTag(value))".

They don't generate the same results, though.  One wraps the value in quotes; the other doesn't.

If the value of the tag I want to set is foo and I do:
ResponseBuilder bldr = Response.ok();
bldr.tag("foo");
The value of the emitted ETag is:  foo

If I do this, though:
ResponseBuilder bldr = Response.ok();
EntityTag tag = new EntityTag("foo");
bldr.tag(tag);
The value of the emitted ETag is: "foo"

This is because org.apache.cxf.jaxrs.impl.ResponseBuilderImpl uses the EntityTag.toString() method to get out the tag value while the String version injects the passed String directly.

This is easy to work around (after you figure out what's happening), but it does seem to be in violation of the interface.

Should the tag(String) method add the quotes to have consistent behavior with the tag(EntityTag) method?


Re: Is there a bug in ResponseBuilder's handling of ETags?

Posted by Sergey Beryozkin <sb...@gmail.com>.
Done...

On Wed, Jul 20, 2011 at 11:33 AM, Sergey Beryozkin <sb...@gmail.com> wrote:
> Hi
>
> On Wed, Jul 20, 2011 at 7:34 AM, Lutz Horn <ti...@posteo.de> wrote:
>> Hi,
>>
>> Am 20.07.2011 03:20, schrieb Barkley, Christopher:
>>> Should the tag(String) method add the quotes to have consistent
>>> behavior with the tag(EntityTag) method?
>>
>> I think both values are legal according to HTTP/1.1. The content of a
>> header field can contain:
>>
>>> the OCTETs making up the field-value and consisting of either *TEXT
>>> or combinations of token, separators, and quoted-string>
>>
>> http://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.2
>>
>> The value 'foo' (without quotes) is legal, as is '"foo"' (with quotes).
>>
>> What happens with a value that dos not pass as a token?
>>
> Thanks for this clarification.
> I don't mind having tag(String) produce the same output as
> tag(EntityTag) just for consistency's sake.
> Cheers, Sergey
>
>> Lutz
>>
>
>
>
> --
> Sergey Beryozkin
>
> http://sberyozkin.blogspot.com
> Talend - http://www.talend.com
>

Re: Is there a bug in ResponseBuilder's handling of ETags?

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

On Wed, Jul 20, 2011 at 7:34 AM, Lutz Horn <ti...@posteo.de> wrote:
> Hi,
>
> Am 20.07.2011 03:20, schrieb Barkley, Christopher:
>> Should the tag(String) method add the quotes to have consistent
>> behavior with the tag(EntityTag) method?
>
> I think both values are legal according to HTTP/1.1. The content of a
> header field can contain:
>
>> the OCTETs making up the field-value and consisting of either *TEXT
>> or combinations of token, separators, and quoted-string>
>
> http://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.2
>
> The value 'foo' (without quotes) is legal, as is '"foo"' (with quotes).
>
> What happens with a value that dos not pass as a token?
>
Thanks for this clarification.
I don't mind having tag(String) produce the same output as
tag(EntityTag) just for consistency's sake.
Cheers, Sergey

> Lutz
>



-- 
Sergey Beryozkin

http://sberyozkin.blogspot.com
Talend - http://www.talend.com

Re: Is there a bug in ResponseBuilder's handling of ETags?

Posted by Lutz Horn <ti...@posteo.de>.
Hi,

Am 20.07.2011 03:20, schrieb Barkley, Christopher:
> Should the tag(String) method add the quotes to have consistent 
> behavior with the tag(EntityTag) method?

I think both values are legal according to HTTP/1.1. The content of a
header field can contain:

> the OCTETs making up the field-value and consisting of either *TEXT
> or combinations of token, separators, and quoted-string>

http://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.2

The value 'foo' (without quotes) is legal, as is '"foo"' (with quotes).

What happens with a value that dos not pass as a token?

Lutz