From 6d890d23a20e88e5a7f64cd9452abd10d7ed2b84 Mon Sep 17 00:00:00 2001 From: Masakazu Kitajo Date: Thu, 25 Jul 2024 16:15:36 -0600 Subject: [PATCH 1/2] Remove TSUrlHttpParamsGet/Set and their internal implementation --- include/proxy/hdrs/HTTP.h | 14 ---------- include/proxy/hdrs/URL.h | 22 ---------------- include/ts/ts.h | 35 ------------------------ src/api/InkAPI.cc | 12 --------- 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 --- 8 files changed, 3 insertions(+), 160 deletions(-) diff --git a/include/proxy/hdrs/HTTP.h b/include/proxy/hdrs/HTTP.h index f0eb0dad678..6e8e8f15dd8 100644 --- a/include/proxy/hdrs/HTTP.h +++ b/include/proxy/hdrs/HTTP.h @@ -565,13 +565,6 @@ class HTTPHdr : public MIMEHdr 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 d115a9c9eeb..e0143346dfe 100644 --- a/include/proxy/hdrs/URL.h +++ b/include/proxy/hdrs/URL.h @@ -302,8 +302,6 @@ class URL : public HdrHeapSDKHandle 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 bc829f10238..76030df541f 100644 --- a/include/ts/ts.h +++ b/include/ts/ts.h @@ -661,41 +661,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 56e3c34ba9d..076c3b8a2fc 100644 --- a/src/api/InkAPI.cc +++ b/src/api/InkAPI.cc @@ -1244,18 +1244,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/proxy/hdrs/URL.cc b/src/proxy/hdrs/URL.cc index 29af18d6029..430d886f81e 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(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 5801acdcc14..18288f18f4a 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(¶m_len); int query_len = 0; const char *query = header.query_get(&query_len); int path_len = value_len + 1; - ts::LocalBuffer buf(value_len + 1 + 1 + 1 + query_len + param_len); + ts::LocalBuffer 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 9c5b3c64131..c6a26030cfa 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 f3b700d7678..c6fb868cb9c 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; From d6f66b306b0a9e9ae770b85580b7de4e9b4507b4 Mon Sep 17 00:00:00 2001 From: Masakazu Kitajo Date: Mon, 29 Jul 2024 15:53:43 -0600 Subject: [PATCH 2/2] Remove the regression test --- src/api/InkAPITest.cc | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/src/api/InkAPITest.cc b/src/api/InkAPITest.cc index 4788d9118a7..82a78196755 100644 --- a/src/api/InkAPITest.cc +++ b/src/api/InkAPITest.cc @@ -3680,8 +3680,6 @@ EXCLUSIVE_REGRESSION_TEST(SDK_API_HttpHookAdd)(RegressionTest *test, int /* atyp // TSUrlPortSet // TSUrlPathGet // TSUrlPathSet -// TSUrlHttpParamsGet -// TSUrlHttpParamsSet // TSUrlHttpQueryGet // TSUrlHttpQuerySet // TSUrlHttpFragmentGet @@ -3941,19 +3939,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");