This is an automated email from the ASF dual-hosted git repository.

cmcfarlen pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git


The following commit(s) were added to refs/heads/master by this push:
     new 1da003e605 Fix case where 206 could be returned for range revalidates 
(#11308)
1da003e605 is described below

commit 1da003e605efffabb221efe52285fba51807cf02
Author: Chris McFarlen <[email protected]>
AuthorDate: Fri May 10 16:09:31 2024 -0600

    Fix case where 206 could be returned for range revalidates (#11308)
    
    * Fix case where 206 could be returned for range revalidates
    
    * remove line
---
 src/proxy/http/HttpSM.cc                             | 11 +++++++----
 .../cache/replay/cache-range-response.replay.yaml    | 20 ++++++++++++++++++++
 2 files changed, 27 insertions(+), 4 deletions(-)

diff --git a/src/proxy/http/HttpSM.cc b/src/proxy/http/HttpSM.cc
index 8a9e929355..f9a23a6576 100644
--- a/src/proxy/http/HttpSM.cc
+++ b/src/proxy/http/HttpSM.cc
@@ -4858,10 +4858,13 @@ HttpSM::do_range_setup_if_necessary()
         }
       } else {
         // if revalidating and cache is stale we want to transform
-        if (t_state.cache_info.action == HttpTransact::CACHE_DO_REPLACE &&
-            t_state.hdr_info.server_response.status_get() == HTTP_STATUS_OK) {
-          Dbg(dbg_ctl_http_range, "Serving transform after stale cache 
re-serve");
-          do_transform = true;
+        if (t_state.cache_info.action == HttpTransact::CACHE_DO_REPLACE) {
+          if (t_state.hdr_info.server_response.status_get() == HTTP_STATUS_OK) 
{
+            Dbg(dbg_ctl_http_range, "Serving transform after stale cache 
re-serve");
+            do_transform = true;
+          } else {
+            Dbg(dbg_ctl_http_range, "Not transforming after revalidate");
+          }
         } else if (cache_sm.cache_read_vc && 
cache_sm.cache_read_vc->is_pread_capable()) {
           // If only one range entry and pread is capable, no need transform 
range
           t_state.range_setup = HttpTransact::RANGE_NOT_TRANSFORM_REQUESTED;
diff --git a/tests/gold_tests/cache/replay/cache-range-response.replay.yaml 
b/tests/gold_tests/cache/replay/cache-range-response.replay.yaml
index 768f0ddd18..0bb4d2271e 100644
--- a/tests/gold_tests/cache/replay/cache-range-response.replay.yaml
+++ b/tests/gold_tests/cache/replay/cache-range-response.replay.yaml
@@ -111,3 +111,23 @@ sessions:
             fields:
               - [ Content-Range, { value: "bytes 0-10/100", as: equal}]
               - [ Via, { value: "uIcSsSfUpSeN:t cCSp sS", as: contains }]
+      # Revalidate and replace still returns appropriate server error
+      - client-request:
+          method: "GET"
+          version: "1.1"
+          url: /some/path
+          headers:
+            fields:
+              - [ Host, example.com ]
+              - [ uuid, 5 ]
+              - [ Range, bytes=0-10 ]
+              - [ If-Modified-Since, "Wed, 16 Mar 2022 22:52:09 GMT"]
+        server-response:
+          status: 404
+          reason: Not Found
+          headers:
+            fields:
+              - [ Content-Length, 10 ]
+              - [ Cache-Control, max-age=300 ]
+        proxy-response:
+          status: 404

Reply via email to