This is an automated email from the ASF dual-hosted git repository. zwoop pushed a commit to branch 8.1.x in repository https://gitbox.apache.org/repos/asf/trafficserver.git
commit 3877af7a0439462cf53c4fe17c28e3a94b5d014c Author: chenggang7 <[email protected]> AuthorDate: Tue Jul 9 11:07:52 2019 +0800 fix If-Match and If-Unmodified-Since priority problem,about rfc https://tools.ietf.org/html/rfc7232#section-3.3 (cherry picked from commit edd6ae44ab791fe88947995edba280db75a2d41e) --- proxy/http/HttpTransactCache.cc | 35 ++++++++++++++--------------------- 1 file changed, 14 insertions(+), 21 deletions(-) diff --git a/proxy/http/HttpTransactCache.cc b/proxy/http/HttpTransactCache.cc index 56adb7b..05a8c3d 100644 --- a/proxy/http/HttpTransactCache.cc +++ b/proxy/http/HttpTransactCache.cc @@ -1307,7 +1307,6 @@ HttpTransactCache::match_response_to_request_conditionals(HTTPHdr *request, HTTP // sub-ranges, we can do a weak validation. // //////////////////////////////////////////////////////////////////////// if (do_strings_match_weakly(raw_etags, raw_etags_len, comma_sep_tag_list, comma_sep_tag_list_len)) { - // the response already failed If-modified-since (if one exists) return HTTP_STATUS_NOT_MODIFIED; } else { return response->status_get(); @@ -1351,24 +1350,6 @@ HttpTransactCache::match_response_to_request_conditionals(HTTPHdr *request, HTTP return response_code; } - // return PRECONDITIONAL_FAILED if either If-unmodified-since - // or If-match fails - // BUT, return the original response code only if both pass - - // If-Unmodified-Since // - if (request->presence(MIME_PRESENCE_IF_UNMODIFIED_SINCE)) { - // lm_value is zero if Last-modified not exists - ink_time_t lm_value = response->get_last_modified(); - - // Condition fails if Last-modified not exists - if ((request->get_if_unmodified_since() < lm_value) || (lm_value == 0)) { - return HTTP_STATUS_PRECONDITION_FAILED; - } else { - // we cannot return yet, need to check If-match - response_code = response->status_get(); - } - } - // If-Match: must match strongly // if (request->presence(MIME_PRESENCE_IF_MATCH)) { int raw_etags_len, comma_sep_tag_list_len; @@ -1390,13 +1371,25 @@ HttpTransactCache::match_response_to_request_conditionals(HTTPHdr *request, HTTP } if (do_strings_match_strongly(raw_etags, raw_etags_len, comma_sep_tag_list, comma_sep_tag_list_len)) { - // at the point, the response passed both If-unmodified-since - // and If-match, so we can return the original response code return response->status_get(); } else { return HTTP_STATUS_PRECONDITION_FAILED; } } + + // If-Unmodified-Since // + if (request->presence(MIME_PRESENCE_IF_UNMODIFIED_SINCE)) { + // lm_value is zero if Last-modified not exists + ink_time_t lm_value = response->get_last_modified(); + + // Condition fails if Last-modified not exists + if ((request->get_if_unmodified_since() < lm_value) || (lm_value == 0)) { + return HTTP_STATUS_PRECONDITION_FAILED; + } else { + response_code = response->status_get(); + } + } + // There is no If-match, and If-unmodified-since passed, // so return the original response code if (response_code != HTTP_STATUS_NONE) {
