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

maskit 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 eb40c5b300 Use the specified `length` characters of the key in 
`Headers::count` (#11405)
eb40c5b300 is described below

commit eb40c5b300a46086e608ae6d3350dad6c7941025
Author: Pavel Vazharov <[email protected]>
AuthorDate: Fri Jun 7 19:45:06 2024 +0300

    Use the specified `length` characters of the key in `Headers::count` 
(#11405)
    
    * Use the specified `length` characters of the key in `Headers::count`
    
    * Remove the additional operator== with std::string_view from tscpp APIs
---
 src/tscpp/api/Headers.cc | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/tscpp/api/Headers.cc b/src/tscpp/api/Headers.cc
index 789cf4dc8b..6b8c51c6e7 100644
--- a/src/tscpp/api/Headers.cc
+++ b/src/tscpp/api/Headers.cc
@@ -594,8 +594,10 @@ Headers::size_type
 Headers::count(const char *key, int length)
 {
   size_type ret_count = 0;
+  size_t    len       = (length < 0) ? strlen(key) : length;
   for (header_field_iterator it = begin(); it != end(); ++it) {
-    if ((*it).name() == key) {
+    HeaderFieldName nm = (*it).name();
+    if ((nm.length() == len) && (::strncasecmp(nm.c_str(), key, len) == 0)) {
       ret_count++;
     }
   }

Reply via email to