You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by zw...@apache.org on 2020/03/26 21:51:13 UTC
[trafficserver] 01/02: A recipient MUST ignore If-Modified-Since if
the request contains an If-None-Match header field,
about rfc https://tools.ietf.org/html/rfc7232#section-3.3
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 1c7f41135639ee65fb7304749ae3bae98ff4f668
Author: chenggang7 <ch...@staff.sina.com.cn>
AuthorDate: Sun Apr 14 21:27:12 2019 +0800
A recipient MUST ignore If-Modified-Since if the request contains an
If-None-Match header field, about rfc https://tools.ietf.org/html/rfc7232#section-3.3
(cherry picked from commit 91b05598bc07d4e8a97281f4d5a556b7956d803e)
---
proxy/http/HttpTransactCache.cc | 59 +++++++++++++++++++----------------------
1 file changed, 27 insertions(+), 32 deletions(-)
diff --git a/proxy/http/HttpTransactCache.cc b/proxy/http/HttpTransactCache.cc
index 0b5ecdf..56adb7b 100644
--- a/proxy/http/HttpTransactCache.cc
+++ b/proxy/http/HttpTransactCache.cc
@@ -1288,6 +1288,33 @@ HttpTransactCache::match_response_to_request_conditionals(HTTPHdr *request, HTTP
return response->status_get();
}
+ // If-None-Match: may match weakly //
+ if (request->presence(MIME_PRESENCE_IF_NONE_MATCH)) {
+ int raw_etags_len, comma_sep_tag_list_len;
+ const char *raw_etags = response->value_get(MIME_FIELD_ETAG, MIME_LEN_ETAG, &raw_etags_len);
+ const char *comma_sep_tag_list = nullptr;
+
+ if (raw_etags) {
+ comma_sep_tag_list = request->value_get(MIME_FIELD_IF_NONE_MATCH, MIME_LEN_IF_NONE_MATCH, &comma_sep_tag_list_len);
+ if (!comma_sep_tag_list) {
+ comma_sep_tag_list = "";
+ comma_sep_tag_list_len = 0;
+ }
+
+ ////////////////////////////////////////////////////////////////////////
+ // If we have an etag and a if-none-match, we are talking to someone //
+ // who is doing a 1.1 revalidate. Since this is a GET request with no //
+ // 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();
+ }
+ }
+ }
+
// If-Modified-Since //
if (request->presence(MIME_PRESENCE_IF_MODIFIED_SINCE)) {
if (response->presence(MIME_PRESENCE_LAST_MODIFIED)) {
@@ -1316,38 +1343,6 @@ HttpTransactCache::match_response_to_request_conditionals(HTTPHdr *request, HTTP
response_code = HTTP_STATUS_NOT_MODIFIED;
}
-
- // we cannot return NOT_MODIFIED yet, need to check If-none-match
- if (!request->presence(MIME_PRESENCE_IF_NONE_MATCH)) {
- return response_code;
- }
- }
-
- // If-None-Match: may match weakly //
- if (request->presence(MIME_PRESENCE_IF_NONE_MATCH)) {
- int raw_etags_len, comma_sep_tag_list_len;
- const char *raw_etags = response->value_get(MIME_FIELD_ETAG, MIME_LEN_ETAG, &raw_etags_len);
- const char *comma_sep_tag_list = nullptr;
-
- if (raw_etags) {
- comma_sep_tag_list = request->value_get(MIME_FIELD_IF_NONE_MATCH, MIME_LEN_IF_NONE_MATCH, &comma_sep_tag_list_len);
- if (!comma_sep_tag_list) {
- comma_sep_tag_list = "";
- comma_sep_tag_list_len = 0;
- }
-
- ////////////////////////////////////////////////////////////////////////
- // If we have an etag and a if-none-match, we are talking to someone //
- // who is doing a 1.1 revalidate. Since this is a GET request with no //
- // 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();
- }
- }
}
// There is no If-none-match, and If-modified-since failed,