users@jersey.java.net

Re: [Jersey] evaluatePreconditions doesn't work

From: Hisaaki Sato <hisato_at_beacon-it.co.jp>
Date: Tue, 24 Feb 2009 09:20:58 +0900 (JST)

Hi Paul,

> If none of the entity tags match, then the server MAY perform the
>requested method as if the If-None-Match
> header field did not exist, but MUST also ignore any If-Modified-
>Since header field(s) in the request. That is, if
> no entity tags match, then the server MUST NOT return a 304 (Not
>Modified) response.
>
>so if there is no match as a result of processing the "If-None-Match"
>we should not process the "If-Modified-Since" header (if present).

I understand what you means and agree the above.:-)

Thank you.
Hisaaki Sato.

--- "Paul Sandoz" <Paul.Sandoz_at_Sun.COM> ---

>
>On Feb 23, 2009, at 12:27 PM, Hisaaki Sato wrote:
>
>> Hi, Paul,
>>
>>> Is it not the case that "If-Modified-Since" should only work with
>>> GET or HEAD
>>> regardless of other precondition headers?
>>
>> Sorry, i don't know other preconditions can be ignored in the above
>> case.
>
>Sorry, i am not being very clear. The HTTP spec states:
>
> If none of the entity tags match, then the server MAY perform the
>requested method as if the If-None-Match
> header field did not exist, but MUST also ignore any If-Modified-
>Since header field(s) in the request. That is, if
> no entity tags match, then the server MUST NOT return a 304 (Not
>Modified) response.
>
>so if there is no match as a result of processing the "If-None-Match"
>we should not process the "If-Modified-Since" header (if present).
>
>
>>
>> but i agree "If-Modified-Since" should only work with GET or HEAD.
>>
>
>OK.
>
>
>>> Would it be possible for you to log an issue?
>>
>> I'll submit this issue later.
>>
>
>Thanks,
>Paul.
>
>[1] http://greenbytes.de/tech/webdav/rfc2616.html#header.if-none-match
>
>> Thanks,
>> Hisaaki Sato.
>>
>> --- "Paul Sandoz" <Paul.Sandoz_at_Sun.COM> ---
>>
>>> Hi Hisaaki,
>>>
>>> I agree i think you found an issue, in the following code:
>>>
>>> public ResponseBuilder evaluatePreconditions(Date lastModified,
>>> EntityTag eTag) {
>>> ResponseBuilder r = evaluateIfMatch(eTag);
>>> if (r == null) {
>>> long lastModifiedTime = lastModified.getTime();
>>> r = evaluateIfUnmodifiedSince(lastModifiedTime);
>>> if (r == null)
>>> r = evaluateIfNoneMatch(eTag);
>>> // If there is no entity tag match for "If-None-Match"
>>> then
>>> // the "If-Modified-Since" header should be ignored
>>> // so that it is not possible to return a 304 Not
>>> Modified response
>>> if (r == null) <------- r == null does not signal that
>>> none of the entity tags match
>>> because the "If-None-
>>> Match" header could be absent
>>>
>>> return null;
>>> r = evaluateIfModifiedSince(lastModifiedTime); <-----
>>> this should only occur if the HTTP method
>>> is
>>> GET or HEAD
>>> if (r != null)
>>> r.tag(eTag);
>>> }
>>>
>>> return r;
>>> }
>>>
>>> And IIUC if there is a match then "If-Modified-Since" processing
>>> should proceed if and only if the HTTP method is "GET" or "HEAD". Is
>>> it not the case that "If-Modified-Since" should only work with GET or
>>> HEAD regardless of other precondition headers?
>>>
>>> Would it be possible for you to log an issue?
>>>
>>> Thanks,
>>> Paul.
>>>
>>> On Feb 23, 2009, at 6:46 AM, Hisaaki Sato wrote:
>>>
>>>> Hi,
>>>>
>>>> I found an issue at the evaluatePreconditions
>>>> method(ContainerRequest).
>>>> It seems re-evaluate after If-Unmodified-Since check and
>>>> precondition failed(412).
>>>> This method should be as follows, I think.
>>>>
>>>> public ResponseBuilder evaluatePreconditions(Date lastModified,
>>>> EntityTag eTag) {
>>>> String ifMatchHeader = getRequestHeaders().getFirst("If-Match");
>>>> String ifNoneMatchHeader = getRequestHeaders().getFirst("If-None-
>>>> Match");
>>>> String ifUnmodifiedSinceHeader = getRequestHeaders().getFirst("If-
>>>> Unmodified-Since");
>>>> String ifModifiedSinceHeader = getRequestHeaders().getFirst("If-
>>>> Modified-Since");
>>>> long lastModifiedTime = lastModified.getTime();
>>>> ResponseBuilder r = null;
>>>> if (ifMatchHeader != null) {
>>>> r = evaluateIfMatch(eTag);
>>>> if (r != null)
>>>> // 412 Precondition Failed
>>>> return r;
>>>> }
>>>> if (ifUnmodifiedSinceHeader != null) {
>>>> r = evaluateIfUnmodifiedSince(lastModifiedTime);
>>>> if (r != null)
>>>> // 412 Precondition Failed
>>>> return r;
>>>> }
>>>> if (ifNoneMatchHeader != null) {
>>>> r = evaluateIfNoneMatch(eTag);
>>>> String httpMethod = getMethod();
>>>> if (r == null || !(httpMethod.equals("GET") ||
>>>> httpMethod.equals("HEAD")))
>>>> // 200 OK
>>>> // 412 Precondition Failed
>>>> return r;
>>>> }
>>>> if (ifModifiedSinceHeader != null) {
>>>> if (r == null) {
>>>> r = evaluateIfModifiedSince(lastModifiedTime);
>>>> } else {
>>>> // 304 Not modified
>>>> // ETag already set by If-None-Match
>>>> if (evaluateIfModifiedSince(lastModifiedTime) == null)
>>>> r == null;
>>>> }
>>>> }
>>>> return r;
>>>> }
>>>>
>>>> Thanks,
>>>> Hisaaki Sato
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
>>>> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
>>> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
>> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
>For additional commands, e-mail: users-help_at_jersey.dev.java.net
>


$B(,(0(,(0(,(0(,(0(,(0(,(0(,(0(,(0(,(0(,(0(,(0(,(0(,(0(,(0(,(0(,(0(,(0(,(0(,(0(B
$B!!>pJs9??e$+$iC&=P$9$k!"#W#e#b(B2.0$B>pJs%]!<%?%k!!!z(BinfoScoop$B!z(B
$B:#!"%(%s%?!<%W%i%$%:$GMxMQ2DG=$J%]!<%?%k$O$3$l$@$1$G$9!#$<$R!"$4Mw$/$@$5$$(B

$B!!!!!!!!"!;0I)El5~(BUFJ$B6d9T$N%7%9%F%`It$r;Y$($k%J%l%C%8%]!<%?%k;vNc"!(B
$B!!!!(Bhttp://www.beacon-it.co.jp/products/solution/ufjis/index.shtml
----------------------------------------------------------------------------
 $B!!-j(BBeacon IT $B%W%m%@%/%H3+H/It(B $BBhFs%A!<%`(B
 $B!!!!!!!!!!:4F#(B $B5WL@(B
 Tel 03(3340)2681 / Fax 03(3340)2614 / Ext: 1116/ 070-6435-1930(PHS)
 E-Mail: hisato@beacon-it.co.jp$B!!!~!!(BURL: http://www.beacon-it.co.jp
$B(,(0(,(0(,(0(,(0(,(0(,(0(,(0(,(0(,(0(,(0(,(0(,(0(,(0(,(0(,(0(,(0(,(0(,(0(,(0(,(0(,(0(B