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

bneradt 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 f919215d2a Make proxy.config.http.cache.post_method overridable 
(#11862)
f919215d2a is described below

commit f919215d2a1e30082c18f8dc423b3c9d5fddaf71
Author: Brian Neradt <[email protected]>
AuthorDate: Thu Nov 14 20:22:55 2024 -0600

    Make proxy.config.http.cache.post_method overridable (#11862)
    
    This makes proxy.config.http.cache.post_method an overridable config.
---
 doc/admin-guide/plugins/lua.en.rst                 |  1 +
 .../api/functions/TSHttpOverridableConfig.en.rst   |  1 +
 .../api/types/TSOverridableConfigKey.en.rst        |  1 +
 include/proxy/http/HttpConfig.h                    |  4 +-
 include/proxy/http/HttpTransactHeaders.h           |  2 +-
 include/ts/apidefs.h.in                            |  1 +
 plugins/lua/ts_lua_http_config.cc                  |  2 +
 src/api/InkAPI.cc                                  |  3 ++
 src/api/InkAPITest.cc                              |  3 +-
 src/proxy/http/HttpConfig.cc                       |  4 +-
 src/proxy/http/HttpTransact.cc                     | 15 ++++----
 src/proxy/http/HttpTransactHeaders.cc              |  2 +-
 src/shared/overridable_txn_vars.cc                 |  1 +
 .../gold_tests/cache/cache-request-method.test.py  | 43 ++++++++++++++++------
 14 files changed, 58 insertions(+), 25 deletions(-)

diff --git a/doc/admin-guide/plugins/lua.en.rst 
b/doc/admin-guide/plugins/lua.en.rst
index c720d640cd..afd0a885d9 100644
--- a/doc/admin-guide/plugins/lua.en.rst
+++ b/doc/admin-guide/plugins/lua.en.rst
@@ -4174,6 +4174,7 @@ Http config constants
     TS_LUA_CONFIG_PLUGIN_VC_DEFAULT_BUFFER_WATER_MARK
     TS_LUA_CONFIG_NET_SOCK_NOTSENT_LOWAT
     TS_LUA_CONFIG_BODY_FACTORY_RESPONSE_SUPPRESSION_MODE
+    TS_LUA_CONFIG_HTTP_CACHE_POST_METHOD
     TS_LUA_CONFIG_LAST_ENTRY
 
 :ref:`TOP <admin-plugins-ts-lua>`
diff --git a/doc/developer-guide/api/functions/TSHttpOverridableConfig.en.rst 
b/doc/developer-guide/api/functions/TSHttpOverridableConfig.en.rst
index 8e2e4b4287..0189c582b3 100644
--- a/doc/developer-guide/api/functions/TSHttpOverridableConfig.en.rst
+++ b/doc/developer-guide/api/functions/TSHttpOverridableConfig.en.rst
@@ -191,6 +191,7 @@ TSOverridableConfigKey Value                                
              Config
 :enumerator:`TS_CONFIG_PLUGIN_VC_DEFAULT_BUFFER_WATER_MARK`             
:ts:cv:`proxy.config.plugin.vc.default_buffer_water_mark`
 :enumerator:`TS_CONFIG_NET_SOCK_NOTSENT_LOWAT`                          
:ts:cv:`proxy.config.net.sock_notsent_lowat`
 :enumerator:`TS_CONFIG_BODY_FACTORY_RESPONSE_SUPPRESSION_MODE`          
:ts:cv:`proxy.config.body_factory.response_suppression_mode`
+:enumerator:`TS_CONFIG_HTTP_CACHE_POST_METHOD`                          
:ts:cv:`proxy.config.http.cache.post_method`
 ======================================================================  
====================================================================
 
 Examples
diff --git a/doc/developer-guide/api/types/TSOverridableConfigKey.en.rst 
b/doc/developer-guide/api/types/TSOverridableConfigKey.en.rst
index efdb71eca0..bb8dec59ba 100644
--- a/doc/developer-guide/api/types/TSOverridableConfigKey.en.rst
+++ b/doc/developer-guide/api/types/TSOverridableConfigKey.en.rst
@@ -158,6 +158,7 @@ Enumeration Members
 .. enumerator:: TS_CONFIG_NET_DEFAULT_INACTIVITY_TIMEOUT
 .. enumerator:: TS_CONFIG_HTTP_NO_DNS_JUST_FORWARD_TO_PARENT
 .. enumerator:: TS_CONFIG_HTTP_CACHE_IGNORE_QUERY
+.. enumerator:: TS_CONFIG_HTTP_CACHE_POST_METHOD
 
 
 Description
diff --git a/include/proxy/http/HttpConfig.h b/include/proxy/http/HttpConfig.h
index a4a0f800d4..c9a5fee1a6 100644
--- a/include/proxy/http/HttpConfig.h
+++ b/include/proxy/http/HttpConfig.h
@@ -526,6 +526,8 @@ struct OverridableHttpConfigParams {
   ////////////////////////
   MgmtByte post_check_content_length_enabled = 1;
 
+  MgmtByte cache_post_method = 0;
+
   ////////////////////////////////////////////////
   // Buffer post body before connecting servers //
   ////////////////////////////////////////////////
@@ -752,8 +754,6 @@ public:
 
   MgmtByte enable_http_stats = 1; // Can be "slow"
 
-  MgmtByte cache_post_method = 0;
-
   MgmtByte push_method_enabled = 0;
 
   MgmtByte referer_filter_enabled  = 0;
diff --git a/include/proxy/http/HttpTransactHeaders.h 
b/include/proxy/http/HttpTransactHeaders.h
index 915313ae57..e2f3f47ae3 100644
--- a/include/proxy/http/HttpTransactHeaders.h
+++ b/include/proxy/http/HttpTransactHeaders.h
@@ -33,7 +33,7 @@ class HttpTransactHeaders
 {
 public:
   static bool is_this_http_method_supported(int method);
-  static bool is_method_cacheable(const HttpConfigParams *http_config_param, 
const int method);
+  static bool is_method_cacheable(const OverridableHttpConfigParams 
*http_config_param, const int method);
   static bool is_method_cache_lookupable(int method);
   static bool is_this_a_hop_by_hop_header(const char *field_name_wks);
   static bool is_this_method_supported(int the_scheme, int the_method);
diff --git a/include/ts/apidefs.h.in b/include/ts/apidefs.h.in
index 886191fc0a..8167886535 100644
--- a/include/ts/apidefs.h.in
+++ b/include/ts/apidefs.h.in
@@ -893,6 +893,7 @@ enum TSOverridableConfigKey {
   TS_CONFIG_HTTP_NO_DNS_JUST_FORWARD_TO_PARENT,
   TS_CONFIG_HTTP_CACHE_IGNORE_QUERY,
   TS_CONFIG_HTTP_DROP_CHUNKED_TRAILERS,
+  TS_CONFIG_HTTP_CACHE_POST_METHOD,
   TS_CONFIG_LAST_ENTRY,
 };
 
diff --git a/plugins/lua/ts_lua_http_config.cc 
b/plugins/lua/ts_lua_http_config.cc
index 93401a1b96..a56a9a9315 100644
--- a/plugins/lua/ts_lua_http_config.cc
+++ b/plugins/lua/ts_lua_http_config.cc
@@ -149,6 +149,7 @@ typedef enum {
   TS_LUA_CONFIG_NET_DEFAULT_INACTIVITY_TIMEOUT                = 
TS_CONFIG_NET_DEFAULT_INACTIVITY_TIMEOUT,
   TS_LUA_CONFIG_HTTP_NO_DNS_JUST_FORWARD_TO_PARENT            = 
TS_CONFIG_HTTP_NO_DNS_JUST_FORWARD_TO_PARENT,
   TS_LUA_CONFIG_HTTP_CACHE_IGNORE_QUERY                       = 
TS_CONFIG_HTTP_CACHE_IGNORE_QUERY,
+  TS_LUA_CONFIG_HTTP_CACHE_POST_METHOD                        = 
TS_CONFIG_HTTP_CACHE_POST_METHOD,
   TS_LUA_CONFIG_LAST_ENTRY                                    = 
TS_CONFIG_LAST_ENTRY,
 } TSLuaOverridableConfigKey;
 
@@ -289,6 +290,7 @@ ts_lua_var_item ts_lua_http_config_vars[] = {
   TS_LUA_MAKE_VAR_ITEM(TS_LUA_CONFIG_NET_DEFAULT_INACTIVITY_TIMEOUT),
   TS_LUA_MAKE_VAR_ITEM(TS_LUA_CONFIG_HTTP_NO_DNS_JUST_FORWARD_TO_PARENT),
   TS_LUA_MAKE_VAR_ITEM(TS_LUA_CONFIG_HTTP_CACHE_IGNORE_QUERY),
+  TS_LUA_MAKE_VAR_ITEM(TS_LUA_CONFIG_HTTP_CACHE_POST_METHOD),
   TS_LUA_MAKE_VAR_ITEM(TS_LUA_CONFIG_LAST_ENTRY),
 };
 
diff --git a/src/api/InkAPI.cc b/src/api/InkAPI.cc
index 79290258dd..d54b8038ff 100644
--- a/src/api/InkAPI.cc
+++ b/src/api/InkAPI.cc
@@ -7323,6 +7323,9 @@ _conf_to_memberp(TSOverridableConfigKey conf, 
OverridableHttpConfigParams *overr
   case TS_CONFIG_HTTP_POST_CHECK_CONTENT_LENGTH_ENABLED:
     ret = 
_memberp_to_generic(&overridableHttpConfig->post_check_content_length_enabled, 
conv);
     break;
+  case TS_CONFIG_HTTP_CACHE_POST_METHOD:
+    ret = _memberp_to_generic(&overridableHttpConfig->cache_post_method, conv);
+    break;
   case TS_CONFIG_HTTP_REQUEST_BUFFER_ENABLED:
     ret = _memberp_to_generic(&overridableHttpConfig->request_buffer_enabled, 
conv);
     break;
diff --git a/src/api/InkAPITest.cc b/src/api/InkAPITest.cc
index dd348d4a6d..f283fa1248 100644
--- a/src/api/InkAPITest.cc
+++ b/src/api/InkAPITest.cc
@@ -8715,7 +8715,8 @@ std::array<std::string_view, TS_CONFIG_LAST_ENTRY> 
SDK_Overridable_Configs = {
    "proxy.config.body_factory.response_suppression_mode", 
"proxy.config.http.parent_proxy.enable_parent_timeout_markdowns",
    "proxy.config.http.parent_proxy.disable_parent_markdowns", 
"proxy.config.net.default_inactivity_timeout",
    "proxy.config.http.no_dns_just_forward_to_parent", 
"proxy.config.http.cache.ignore_query",
-   "proxy.config.http.drop_chunked_trailers", }
+   "proxy.config.http.drop_chunked_trailers", 
"proxy.config.http.cache.post_method",
+   }
 };
 
 extern ClassAllocator<HttpSM> httpSMAllocator;
diff --git a/src/proxy/http/HttpConfig.cc b/src/proxy/http/HttpConfig.cc
index 88e12859bf..1f369fcc45 100644
--- a/src/proxy/http/HttpConfig.cc
+++ b/src/proxy/http/HttpConfig.cc
@@ -789,6 +789,7 @@ HttpConfig::startup()
   HttpEstablishStaticConfigLongLong(c.oride.flow_high_water_mark, 
"proxy.config.http.flow_control.high_water");
   HttpEstablishStaticConfigLongLong(c.oride.flow_low_water_mark, 
"proxy.config.http.flow_control.low_water");
   HttpEstablishStaticConfigByte(c.oride.post_check_content_length_enabled, 
"proxy.config.http.post.check.content_length.enabled");
+  HttpEstablishStaticConfigByte(c.oride.cache_post_method, 
"proxy.config.http.cache.post_method");
   HttpEstablishStaticConfigByte(c.oride.request_buffer_enabled, 
"proxy.config.http.request_buffer_enabled");
   HttpEstablishStaticConfigByte(c.strict_uri_parsing, 
"proxy.config.http.strict_uri_parsing");
 
@@ -923,7 +924,6 @@ HttpConfig::startup()
   HttpEstablishStaticConfigByte(c.oride.cache_ignore_auth, 
"proxy.config.http.cache.ignore_authentication");
   HttpEstablishStaticConfigByte(c.oride.cache_urls_that_look_dynamic, 
"proxy.config.http.cache.cache_urls_that_look_dynamic");
   HttpEstablishStaticConfigByte(c.oride.cache_ignore_query, 
"proxy.config.http.cache.ignore_query");
-  HttpEstablishStaticConfigByte(c.cache_post_method, 
"proxy.config.http.cache.post_method");
 
   HttpEstablishStaticConfigByte(c.oride.ignore_accept_mismatch, 
"proxy.config.http.cache.ignore_accept_mismatch");
   HttpEstablishStaticConfigByte(c.oride.ignore_accept_language_mismatch, 
"proxy.config.http.cache.ignore_accept_language_mismatch");
@@ -1086,6 +1086,7 @@ HttpConfig::reconfigure()
   params->oride.http_chunking_size = m_master.oride.http_chunking_size;
 
   params->oride.post_check_content_length_enabled = 
INT_TO_BOOL(m_master.oride.post_check_content_length_enabled);
+  params->oride.cache_post_method                 = 
INT_TO_BOOL(m_master.oride.cache_post_method);
 
   params->oride.request_buffer_enabled = 
INT_TO_BOOL(m_master.oride.request_buffer_enabled);
 
@@ -1215,7 +1216,6 @@ HttpConfig::reconfigure()
   params->oride.cache_ignore_auth              = 
INT_TO_BOOL(m_master.oride.cache_ignore_auth);
   params->oride.cache_urls_that_look_dynamic   = 
INT_TO_BOOL(m_master.oride.cache_urls_that_look_dynamic);
   params->oride.cache_ignore_query             = 
INT_TO_BOOL(m_master.oride.cache_ignore_query);
-  params->cache_post_method                    = 
INT_TO_BOOL(m_master.cache_post_method);
 
   params->oride.ignore_accept_mismatch          = 
m_master.oride.ignore_accept_mismatch;
   params->oride.ignore_accept_language_mismatch = 
m_master.oride.ignore_accept_language_mismatch;
diff --git a/src/proxy/http/HttpTransact.cc b/src/proxy/http/HttpTransact.cc
index 1feade28ee..a2155352c2 100644
--- a/src/proxy/http/HttpTransact.cc
+++ b/src/proxy/http/HttpTransact.cc
@@ -21,6 +21,7 @@
   limitations under the License.
  */
 
+#include "proxy/http/HttpConfig.h"
 #include "tscore/ink_inet.h"
 #include "tsutil/ts_bw_format.h"
 
@@ -776,7 +777,7 @@ do_cookies_prevent_caching(int cookies_conf, HTTPHdr 
*request, HTTPHdr *response
 }
 
 inline static bool
-does_method_require_cache_copy_deletion(const HttpConfigParams 
*http_config_param, const int method)
+does_method_require_cache_copy_deletion(const OverridableHttpConfigParams 
*http_config_param, const int method)
 {
   return ((method != HTTP_WKSIDX_GET) &&
           (method == HTTP_WKSIDX_DELETE || method == HTTP_WKSIDX_PURGE || 
method == HTTP_WKSIDX_PUT ||
@@ -2053,7 +2054,7 @@ HttpTransact::OSDNSLookup(State *s)
       } else if (s->cache_lookup_result == CACHE_LOOKUP_MISS || 
s->cache_info.action == CACHE_DO_NO_ACTION) {
         TRANSACT_RETURN(SM_ACTION_API_OS_DNS, HandleCacheOpenReadMiss);
         // DNS lookup is done if the lookup failed and need to call Handle 
Cache Open Read Miss
-      } else if (s->cache_info.action == CACHE_PREPARE_TO_WRITE && 
s->http_config_param->cache_post_method == 1 &&
+      } else if (s->cache_info.action == CACHE_PREPARE_TO_WRITE && 
s->txn_conf->cache_post_method == 1 &&
                  s->method == HTTP_WKSIDX_POST) {
         // By virtue of being here, we are intending to forward the request on
         // to the server. If we marked this as CACHE_PREPARE_TO_WRITE and this
@@ -2452,7 +2453,7 @@ HttpTransact::issue_revalidate(State *s)
     // request to the server. is_cache_response_returnable will ensure
     // that we forward the request. We now specify what the cache
     // action should be when the response is received.
-    if (does_method_require_cache_copy_deletion(s->http_config_param, 
s->method)) {
+    if (does_method_require_cache_copy_deletion(s->txn_conf, s->method)) {
       s->cache_info.action = CACHE_PREPARE_TO_DELETE;
       TxnDbg(dbg_ctl_http_seq, "cache action: DELETE");
     } else {
@@ -3044,7 +3045,7 @@ HttpTransact::build_response_from_cache(State *s, 
HTTPWarningCode warning_code)
   // fall through
   default:
     SET_VIA_STRING(VIA_DETAIL_CACHE_LOOKUP, VIA_DETAIL_HIT_SERVED);
-    if (s->method == HTTP_WKSIDX_GET || 
(s->http_config_param->cache_post_method == 1 && s->method == HTTP_WKSIDX_POST) 
||
+    if (s->method == HTTP_WKSIDX_GET || (s->txn_conf->cache_post_method == 1 
&& s->method == HTTP_WKSIDX_POST) ||
         s->api_resp_cacheable == true) {
       // send back the full document to the client.
       TxnDbg(dbg_ctl_http_trans, "Match! Serving full document.");
@@ -3278,7 +3279,7 @@ HttpTransact::HandleCacheOpenReadMiss(State *s)
   }
   // We do a cache lookup for some non-GET requests as well.
   // We must, however, not cache the responses to these requests.
-  if (does_method_require_cache_copy_deletion(s->http_config_param, s->method) 
&& s->api_req_cacheable == false) {
+  if (does_method_require_cache_copy_deletion(s->txn_conf, s->method) && 
s->api_req_cacheable == false) {
     s->cache_info.action = CACHE_DO_NO_ACTION;
   } else if ((s->hdr_info.client_request.presence(MIME_PRESENCE_RANGE) && 
!s->txn_conf->cache_range_write) ||
              does_method_effect_cache(s->method) == false || s->range_setup == 
RANGE_NOT_SATISFIABLE ||
@@ -5904,7 +5905,7 @@ HttpTransact::is_cache_response_returnable(State *s)
     return false;
   }
 
-  if (!HttpTransactHeaders::is_method_cacheable(s->http_config_param, 
s->method) && s->api_resp_cacheable == false) {
+  if (!HttpTransactHeaders::is_method_cacheable(s->txn_conf, s->method) && 
s->api_resp_cacheable == false) {
     SET_VIA_STRING(VIA_CACHE_RESULT, VIA_IN_CACHE_NOT_ACCEPTABLE);
     SET_VIA_STRING(VIA_DETAIL_CACHE_LOOKUP, VIA_DETAIL_MISS_METHOD);
     return false;
@@ -6184,7 +6185,7 @@ HttpTransact::is_response_cacheable(State *s, HTTPHdr 
*request, HTTPHdr *respons
   // Basically, the problem is the resp for POST url1 req should not
   // be served to a GET url1 request, but we just match URL not method.
   int req_method = request->method_get_wksidx();
-  if (!(HttpTransactHeaders::is_method_cacheable(s->http_config_param, 
req_method)) && s->api_req_cacheable == false) {
+  if (!(HttpTransactHeaders::is_method_cacheable(s->txn_conf, req_method)) && 
s->api_req_cacheable == false) {
     TxnDbg(dbg_ctl_http_trans, "only GET, and some HEAD and POST are 
cacheable");
     return false;
   }
diff --git a/src/proxy/http/HttpTransactHeaders.cc 
b/src/proxy/http/HttpTransactHeaders.cc
index a2bdc2b645..7f730d7db1 100644
--- a/src/proxy/http/HttpTransactHeaders.cc
+++ b/src/proxy/http/HttpTransactHeaders.cc
@@ -50,7 +50,7 @@ DbgCtl dbg_ctl_anon{"anon"};
 } // end anonymous namespace
 
 bool
-HttpTransactHeaders::is_method_cacheable(const HttpConfigParams 
*http_config_param, const int method)
+HttpTransactHeaders::is_method_cacheable(const OverridableHttpConfigParams 
*http_config_param, const int method)
 {
   return (method == HTTP_WKSIDX_GET || method == HTTP_WKSIDX_HEAD ||
           (http_config_param->cache_post_method == 1 && method == 
HTTP_WKSIDX_POST));
diff --git a/src/shared/overridable_txn_vars.cc 
b/src/shared/overridable_txn_vars.cc
index 0181c32bba..5626559323 100644
--- a/src/shared/overridable_txn_vars.cc
+++ b/src/shared/overridable_txn_vars.cc
@@ -131,6 +131,7 @@ const std::unordered_map<std::string_view, std::tuple<const 
TSOverridableConfigK
      {TS_CONFIG_HTTP_KEEP_ALIVE_NO_ACTIVITY_TIMEOUT_IN, TS_RECORDDATATYPE_INT} 
                                                                 },
     {"proxy.config.http.post.check.content_length.enabled",
      {TS_CONFIG_HTTP_POST_CHECK_CONTENT_LENGTH_ENABLED, TS_RECORDDATATYPE_INT} 
                                                                 },
+    {"proxy.config.http.cache.post_method",                            
{TS_CONFIG_HTTP_CACHE_POST_METHOD, TS_RECORDDATATYPE_INT}                },
     {"proxy.config.http.cache.cache_urls_that_look_dynamic",
      {TS_CONFIG_HTTP_CACHE_CACHE_URLS_THAT_LOOK_DYNAMIC, 
TS_RECORDDATATYPE_INT}                                                          
       },
     {"proxy.config.http.transaction_no_activity_timeout_in",
diff --git a/tests/gold_tests/cache/cache-request-method.test.py 
b/tests/gold_tests/cache/cache-request-method.test.py
index 8cd483e1a3..21fd65517d 100644
--- a/tests/gold_tests/cache/cache-request-method.test.py
+++ b/tests/gold_tests/cache/cache-request-method.test.py
@@ -23,9 +23,10 @@ Verify correct caching behavior with respect to request 
method.
 
 # Test 0: Verify correct POST response handling when caching POST responses is
 # disabled.
-ts = Test.MakeATSProcess("ts")
+tr = Test.AddTestRun("Verify correct with POST response caching disabled.")
+ts = tr.MakeATSProcess("ts")
 replay_file = "replay/post_with_post_caching_disabled.replay.yaml"
-server = Test.MakeVerifierServerProcess("server0", replay_file)
+server = tr.AddVerifierServerProcess("server0", replay_file)
 ts.Disk.records_config.update(
     {
         'proxy.config.diags.debug.enabled': 1,
@@ -37,16 +38,16 @@ ts.Disk.records_config.update(
         # 'proxy.config.http.cache.post_method': 0,
     })
 ts.Disk.remap_config.AddLine('map / 
http://127.0.0.1:{0}'.format(server.Variables.http_port))
-tr = Test.AddTestRun("Verify correct with POST response caching disabled.")
 tr.Processes.Default.StartBefore(server)
 tr.Processes.Default.StartBefore(ts)
 tr.AddVerifierClientProcess("client0", replay_file, 
http_ports=[ts.Variables.port])
 
 # Test 1: Verify correct POST response handling when caching POST responses is
 # enabled.
-ts = Test.MakeATSProcess("ts-cache-post")
+tr = Test.AddTestRun("Verify correct with POST response caching enabled.")
+ts = tr.MakeATSProcess("ts-cache-post")
 replay_file = "replay/post_with_post_caching_enabled.replay.yaml"
-server = Test.MakeVerifierServerProcess("server1", replay_file)
+server = tr.AddVerifierServerProcess("server1", replay_file)
 ts.Disk.records_config.update(
     {
         'proxy.config.diags.debug.enabled': 1,
@@ -55,15 +56,36 @@ ts.Disk.records_config.update(
         'proxy.config.http.cache.post_method': 1,
     })
 ts.Disk.remap_config.AddLine('map / 
http://127.0.0.1:{0}'.format(server.Variables.http_port))
-tr = Test.AddTestRun("Verify correct with POST response caching enabled.")
 tr.Processes.Default.StartBefore(server)
 tr.Processes.Default.StartBefore(ts)
 tr.AddVerifierClientProcess("client1", replay_file, 
http_ports=[ts.Variables.port])
 
-# Test 2: Verify correct HEAD response handling with cached GET response
-ts = Test.MakeATSProcess("ts-cache-head")
+# Test 2: Verify correct POST response handling when caching POST responses is
+# enabled via an overridable config.
+tr = Test.AddTestRun("Verify correct with POST response caching enabled 
overridably.")
+ts = tr.MakeATSProcess("ts-cache-post-override")
+replay_file = "replay/post_with_post_caching_enabled.replay.yaml"
+server = tr.AddVerifierServerProcess("server2", replay_file)
+ts.Disk.records_config.update(
+    {
+        'proxy.config.diags.debug.enabled': 1,
+        'proxy.config.diags.debug.tags': 'http.*|cache.*',
+        'proxy.config.http.insert_age_in_response': 0,
+        # Override the following in remap.config.
+        'proxy.config.http.cache.post_method': 0,
+    })
+ts.Disk.remap_config.AddLine(
+    f'map / http://127.0.0.1:{server.Variables.http_port} '
+    '@plugin=conf_remap.so @pparam=proxy.config.http.cache.post_method=1')
+tr.Processes.Default.StartBefore(server)
+tr.Processes.Default.StartBefore(ts)
+tr.AddVerifierClientProcess("client2", replay_file, 
http_ports=[ts.Variables.port])
+
+# Test 3: Verify correct HEAD response handling with cached GET response
+tr = Test.AddTestRun("Verify correct with HEAD response.")
+ts = tr.MakeATSProcess("ts-cache-head")
 replay_file = "replay/head_with_get_cached.replay.yaml"
-server = Test.MakeVerifierServerProcess("server2", replay_file)
+server = tr.AddVerifierServerProcess("server3", replay_file)
 ts.Disk.records_config.update(
     {
         'proxy.config.diags.debug.enabled': 1,
@@ -71,7 +93,6 @@ ts.Disk.records_config.update(
         'proxy.config.http.insert_age_in_response': 0,
     })
 ts.Disk.remap_config.AddLine('map / 
http://127.0.0.1:{0}'.format(server.Variables.http_port))
-tr = Test.AddTestRun("Verify correct with HEAD response.")
 tr.Processes.Default.StartBefore(server)
 tr.Processes.Default.StartBefore(ts)
-tr.AddVerifierClientProcess("client2", replay_file, 
http_ports=[ts.Variables.port])
+tr.AddVerifierClientProcess("client3", replay_file, 
http_ports=[ts.Variables.port])

Reply via email to