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

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


The following commit(s) were added to refs/heads/9.2.x by this push:
     new 664f1ef4ab Use the specified `length` characters of the key in 
`Headers::count` (#11405) (#11971)
664f1ef4ab is described below

commit 664f1ef4abfb4ca8b703f0554c64fa52d5cc460b
Author: Evan Zelkowitz <[email protected]>
AuthorDate: Thu Jan 16 15:25:33 2025 -0700

    Use the specified `length` characters of the key in `Headers::count` 
(#11405) (#11971)
    
    * 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
    
    (cherry picked from commit eb40c5b300a46086e608ae6d3350dad6c7941025)
    
    * Fix format
    
    ---------
    
    Co-authored-by: Pavel Vazharov <[email protected]>
---
 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 6b19ffdc17..b5a24a3884 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