Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 0 additions & 14 deletions include/proxy/hdrs/HTTP.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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)
{
Expand Down
22 changes: 0 additions & 22 deletions include/proxy/hdrs/URL.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
}

/*-------------------------------------------------------------------------
-------------------------------------------------------------------------*/

Expand Down
35 changes: 0 additions & 35 deletions include/ts/ts.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 0 additions & 12 deletions src/api/InkAPI.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
15 changes: 0 additions & 15 deletions src/api/InkAPITest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3680,8 +3680,6 @@ EXCLUSIVE_REGRESSION_TEST(SDK_API_HttpHookAdd)(RegressionTest *test, int /* atyp
// TSUrlPortSet
// TSUrlPathGet
// TSUrlPathSet
// TSUrlHttpParamsGet
// TSUrlHttpParamsSet
// TSUrlHttpQueryGet
// TSUrlHttpQuerySet
// TSUrlHttpFragmentGet
Expand Down Expand Up @@ -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");
Expand Down
38 changes: 2 additions & 36 deletions src/proxy/hdrs/URL.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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;
}

/*-------------------------------------------------------------------------
-------------------------------------------------------------------------*/

Expand Down
9 changes: 1 addition & 8 deletions src/proxy/hdrs/VersionConverter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
29 changes: 0 additions & 29 deletions src/proxy/hdrs/unit_tests/test_URL.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
4 changes: 0 additions & 4 deletions src/proxy/http/HttpTransact.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down