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

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

commit 8904861b1bb557b88d97b1006eb9ccb0bb847f34
Author: Masakazu Kitajo <[email protected]>
AuthorDate: Mon Aug 5 15:47:57 2024 -0600

    Remove TSUrlHttpParamsGet/Set and their internal implementation (#11624)
    
    * Remove TSUrlHttpParamsGet/Set and their internal implementation
    
    * Remove the regression test
    
    (cherry picked from commit c654244987156fc9f51ac224b673dc6d62389d6f)
---
 include/proxy/hdrs/HTTP.h             | 14 -------------
 include/proxy/hdrs/URL.h              | 22 --------------------
 include/ts/ts.h                       | 35 --------------------------------
 src/api/InkAPI.cc                     | 12 -----------
 src/api/InkAPITest.cc                 | 15 --------------
 src/proxy/hdrs/URL.cc                 | 38 ++---------------------------------
 src/proxy/hdrs/VersionConverter.cc    |  9 +--------
 src/proxy/hdrs/unit_tests/test_URL.cc | 29 --------------------------
 src/proxy/http/HttpTransact.cc        |  4 ----
 9 files changed, 3 insertions(+), 175 deletions(-)

diff --git a/include/proxy/hdrs/HTTP.h b/include/proxy/hdrs/HTTP.h
index f0eb0dad67..6e8e8f15dd 100644
--- a/include/proxy/hdrs/HTTP.h
+++ b/include/proxy/hdrs/HTTP.h
@@ -565,13 +565,6 @@ public:
   const char *path_get(int *length ///< Storage for path length.
   );
 
-  /** Get the URL matrix params.
-      This is a reference, not allocated.
-      @return A pointer to the matrix params or @c NULL if there is no valid 
URL.
-  */
-  const char *params_get(int *length ///< Storage for param length.
-  );
-
   /** Get the URL query.
       This is a reference, not allocated.
       @return A pointer to the query or @c NULL if there is no valid URL.
@@ -1214,13 +1207,6 @@ HTTPHdr::path_get(int *length)
   return url ? url->path_get(length) : nullptr;
 }
 
-inline const char *
-HTTPHdr::params_get(int *length)
-{
-  URL *url = this->url_get();
-  return url ? url->params_get(length) : nullptr;
-}
-
 inline const char *
 HTTPHdr::query_get(int *length)
 {
diff --git a/include/proxy/hdrs/URL.h b/include/proxy/hdrs/URL.h
index d115a9c9ee..e0143346df 100644
--- a/include/proxy/hdrs/URL.h
+++ b/include/proxy/hdrs/URL.h
@@ -302,8 +302,6 @@ public:
   int  type_code_get();
   void type_code_set(int type);
 
-  const char *params_get(int *length);
-  void        params_set(const char *value, int length);
   const char *query_get(int *length);
   void        query_set(const char *value, int length);
   const char *fragment_get(int *length);
@@ -676,26 +674,6 @@ URL::type_code_set(int typecode)
   m_url_impl->set_type_code(typecode);
 }
 
-/*-------------------------------------------------------------------------
-  -------------------------------------------------------------------------*/
-
-inline const char *
-URL::params_get(int *length)
-{
-  ink_assert(valid());
-  return m_url_impl->get_params(length);
-}
-
-/*-------------------------------------------------------------------------
-  -------------------------------------------------------------------------*/
-
-inline void
-URL::params_set(const char *value, int length)
-{
-  ink_assert(valid());
-  m_url_impl->set_params(m_heap, value, length, true);
-}
-
 /*-------------------------------------------------------------------------
   -------------------------------------------------------------------------*/
 
diff --git a/include/ts/ts.h b/include/ts/ts.h
index 95be90f3a6..f6203b81da 100644
--- a/include/ts/ts.h
+++ b/include/ts/ts.h
@@ -660,41 +660,6 @@ TSReturnCode TSUrlFtpTypeSet(TSMBuffer bufp, TSMLoc 
offset, int type);
 
 /* --------------------------------------------------------------------------
    HTTP specific URLs */
-/**
-    Retrieves the HTTP params portion of the URL located at url_loc
-    within bufp. The length of the returned string is in the length
-    argument. Note: the returned string is not guaranteed to be
-    null-terminated.
-
-    This function is deprecated and returns empty string.
-    Plugins that need "params" can call TSUrlPathGet to get a whole path 
string to parse it.
-
-    @param bufp marshal buffer containing the URL.
-    @param offset location of the URL.
-    @param length of the returned string.
-    @return HTTP params portion of the URL.
-
- */
-const char *TSUrlHttpParamsGet(TSMBuffer bufp, TSMLoc offset, int *length);
-
-/**
-    Sets the HTTP params portion of the URL located at url_loc within
-    bufp to the string value. If length is -1 that TSUrlHttpParamsSet()
-    assumes that value is null-terminated. Otherwise, the length of
-    the string value is taken to be length. TSUrlHttpParamsSet()
-    copies the string to within bufp, so you can modify or delete
-    value after calling TSUrlHttpParamsSet().
-
-    This function is deprecated. The value passed will be internally appended 
to the path portion.
-    Thus, TSUrlHttpParamsGet will not return the value set by this function.
-
-    @param bufp marshal buffer containing the URL.
-    @param offset location of the URL.
-    @param value HTTP params string to set in the URL.
-    @param length string length of the new HTTP params value.
-
- */
-TSReturnCode TSUrlHttpParamsSet(TSMBuffer bufp, TSMLoc offset, const char 
*value, int length);
 
 /**
     Retrieves the HTTP query portion of the URL located at url_loc
diff --git a/src/api/InkAPI.cc b/src/api/InkAPI.cc
index 1057da355a..60e5379693 100644
--- a/src/api/InkAPI.cc
+++ b/src/api/InkAPI.cc
@@ -1242,18 +1242,6 @@ TSUrlFtpTypeSet(TSMBuffer bufp, TSMLoc obj, int type)
 
 /* HTTP specific URLs */
 
-const char *
-TSUrlHttpParamsGet(TSMBuffer bufp, TSMLoc obj, int *length)
-{
-  return URLPartGet(bufp, obj, length, &URL::params_get);
-}
-
-TSReturnCode
-TSUrlHttpParamsSet(TSMBuffer bufp, TSMLoc obj, const char *value, int length)
-{
-  return URLPartSet(bufp, obj, value, length, &URL::params_set);
-}
-
 const char *
 TSUrlHttpQueryGet(TSMBuffer bufp, TSMLoc obj, int *length)
 {
diff --git a/src/api/InkAPITest.cc b/src/api/InkAPITest.cc
index 091be30c85..f2c818f7d3 100644
--- a/src/api/InkAPITest.cc
+++ b/src/api/InkAPITest.cc
@@ -3667,8 +3667,6 @@ 
EXCLUSIVE_REGRESSION_TEST(SDK_API_HttpHookAdd)(RegressionTest *test, int /* atyp
 //                    TSUrlPortSet
 //                    TSUrlPathGet
 //                    TSUrlPathSet
-//                    TSUrlHttpParamsGet
-//                    TSUrlHttpParamsSet
 //                    TSUrlHttpQueryGet
 //                    TSUrlHttpQuerySet
 //                    TSUrlHttpFragmentGet
@@ -3925,19 +3923,6 @@ REGRESSION_TEST(SDK_API_TSUrl)(RegressionTest *test, int 
/* atype ATS_UNUSED */,
     }
   }
 
-  // Params
-  if (TSUrlHttpParamsSet(bufp1, url_loc1, params, -1) != TS_SUCCESS) {
-    SDK_RPRINT(test, "TSUrlHttpParamsSet", "TestCase1", TC_FAIL, "Returned 
TS_ERROR");
-  } else {
-    params_get = TSUrlHttpParamsGet(bufp1, url_loc1, &length);
-    if (params_get != nullptr && strncmp(params, params_get, length) == 0) {
-      SDK_RPRINT(test, "TSUrlHttpParamsSet&Get", "TestCase1", TC_PASS, "ok");
-      test_passed_params = true;
-    } else {
-      SDK_RPRINT(test, "TSUrlHttpParamsSet&Get", "TestCase1", TC_FAIL, "Values 
don't match");
-    }
-  }
-
   // Query
   if (TSUrlHttpQuerySet(bufp1, url_loc1, query, -1) != TS_SUCCESS) {
     SDK_RPRINT(test, "TSUrlHttpQuerySet", "TestCase1", TC_FAIL, "Returned 
TS_ERROR");
diff --git a/src/proxy/hdrs/URL.cc b/src/proxy/hdrs/URL.cc
index 29af18d602..430d886f81 100644
--- a/src/proxy/hdrs/URL.cc
+++ b/src/proxy/hdrs/URL.cc
@@ -545,32 +545,8 @@ URLImpl::set_path(HdrHeap *heap, const char *value, int 
length, bool copy_string
 /*-------------------------------------------------------------------------
   -------------------------------------------------------------------------*/
 
-// empties params/query/fragment component
-// url_{params|query|fragment}_set()
-
-void
-URLImpl::set_params(HdrHeap *heap, const char *value, int length, bool /* 
copy_string ATS_UNUSED */)
-{
-  int path_len = this->m_len_path;
-
-  // Truncate the current param segment if it exists
-  if (auto p = strchr(this->m_ptr_path, ';'); p != nullptr) {
-    auto params_len  = path_len - (p - this->m_ptr_path);
-    path_len        -= params_len;
-  }
-
-  int   total_length    = path_len + 1 + length;
-  char *path_and_params = static_cast<char *>(alloca(total_length));
-
-  memcpy(path_and_params, this->m_ptr_path, path_len);
-  memcpy(path_and_params + path_len, ";", 1);
-  memcpy(path_and_params + path_len + 1, value, length);
-
-  this->set_path(heap, path_and_params, total_length, true);
-}
-
-/*-------------------------------------------------------------------------
-  -------------------------------------------------------------------------*/
+// empties query/fragment component
+// url_{query|fragment}_set()
 
 void
 URLImpl::set_query(HdrHeap *heap, const char *value, int length, bool 
copy_string)
@@ -792,16 +768,6 @@ URLImpl::get_path(int *length)
   return this->m_ptr_path;
 }
 
-/*-------------------------------------------------------------------------
-  -------------------------------------------------------------------------*/
-
-const char *
-URLImpl::get_params(int *length)
-{
-  *length = this->m_len_params;
-  return this->m_ptr_params;
-}
-
 /*-------------------------------------------------------------------------
   -------------------------------------------------------------------------*/
 
diff --git a/src/proxy/hdrs/VersionConverter.cc 
b/src/proxy/hdrs/VersionConverter.cc
index 5801acdcc1..18288f18f4 100644
--- a/src/proxy/hdrs/VersionConverter.cc
+++ b/src/proxy/hdrs/VersionConverter.cc
@@ -122,21 +122,14 @@ VersionConverter::_convert_req_from_1_to_2(HTTPHdr 
&header) const
   if (MIMEField *field = header.field_find(PSEUDO_HEADER_PATH.data(), 
PSEUDO_HEADER_PATH.size()); field != nullptr) {
     int         value_len = 0;
     const char *value     = header.path_get(&value_len);
-    int         param_len = 0;
-    const char *param     = header.params_get(&param_len);
     int         query_len = 0;
     const char *query     = header.query_get(&query_len);
     int         path_len  = value_len + 1;
 
-    ts::LocalBuffer<char> buf(value_len + 1 + 1 + 1 + query_len + param_len);
+    ts::LocalBuffer<char> buf(value_len + 1 + 1 + 1 + query_len);
     char                 *path = buf.data();
     path[0]                    = '/';
     memcpy(path + 1, value, value_len);
-    if (param_len > 0) {
-      path[path_len] = ';';
-      memcpy(path + path_len + 1, param, param_len);
-      path_len += 1 + param_len;
-    }
     if (query_len > 0) {
       path[path_len] = '?';
       memcpy(path + path_len + 1, query, query_len);
diff --git a/src/proxy/hdrs/unit_tests/test_URL.cc 
b/src/proxy/hdrs/unit_tests/test_URL.cc
index 9c5b3c6413..c6a26030cf 100644
--- a/src/proxy/hdrs/unit_tests/test_URL.cc
+++ b/src/proxy/hdrs/unit_tests/test_URL.cc
@@ -750,32 +750,3 @@ TEST_CASE("UrlPathGet", "[url][path_get]")
     }
   }
 }
-
-
-/**
- * Tests for deprecated params_get/set
- */
-TEST_CASE("UrlParamsGet", "[url][params_get]")
-{
-  // Expected behavior
-  // - ParamsGet always return empty string
-  // - ParamsSet appends the value to path
-  // - PathGet returns params appended by ParamsSet
-
-  const char *value;
-  int value_len;
-
-  URL url;
-  HdrHeap *heap = new_HdrHeap();
-  url.create(heap);
-  url.parse("https://foo.test/path;p=1";);
-  value = url.path_get(&value_len);
-  CHECK(std::string_view(value, value_len) == "path;p=1");
-  url.params_set("param=1", 7);
-  value = url.params_get(&value_len);
-  CHECK(value == nullptr);
-  CHECK(value_len == 0);
-  value = url.path_get(&value_len);
-  CHECK(std::string_view(value, value_len) == "path;param=1");
-  heap->destroy();
-}
diff --git a/src/proxy/http/HttpTransact.cc b/src/proxy/http/HttpTransact.cc
index f3b700d767..c6fb868cb9 100644
--- a/src/proxy/http/HttpTransact.cc
+++ b/src/proxy/http/HttpTransact.cc
@@ -5992,10 +5992,6 @@ HttpTransact::url_looks_dynamic(URL *url)
   // (1) If URL contains query stuff in it, call it dynamic //
   ////////////////////////////////////////////////////////////
 
-  part = url->params_get(&part_length);
-  if (part != nullptr) {
-    return true;
-  }
   part = url->query_get(&part_length);
   if (part != nullptr) {
     return true;

Reply via email to