masaori335 commented on PR #13119:
URL: https://github.com/apache/trafficserver/pull/13119#issuecomment-4333001759

   I introduced a new helper function, `bool iequals(const std::string_view 
&lhs, const std::string_view &rhs)`, simple equality check case-insensitivly.
   
   I found 3b0f0b760387af0c4f6fdd40c4bc98f14dbf0c4d did the same change in 
three places, so this PR restores length check with `ts::iequals`.
   ```
   git show 3b0f0b760387af0c4f6fdd40c4bc98f14dbf0c4d | grep -B 10 strcasecmp
    {
      MIMEFieldBlockImpl *fblock;
      MIMEField          *field, *too_far_field;
   @@ -1277,8 +1117,9 @@ _mime_hdr_field_list_search_by_string(MIMEHdrImpl *mh, 
const char *field_name_st
    
        too_far_field = &(fblock->m_field_slots[fblock->m_freetop]);
        while (field < too_far_field) {
   -      if (field->is_live() && (field_name_len == field->m_len_name) &&
   -          (strncasecmp(field->m_ptr_name, field_name_str, field_name_len) 
== 0)) {
   +      if (field->is_live() &&
   +          strcasecmp(std::string_view{field->m_ptr_name, 
static_cast<std::string_view::size_type>(field->m_len_name)},
   --
   --- a/src/proxy/http/HttpSM.cc
   +++ b/src/proxy/http/HttpSM.cc
   @@ -735,9 +735,9 @@ HttpSM::state_read_client_request_header(int event, void 
*data)
        if (t_state.hdr_info.client_request.version_get() == HTTP_1_1 &&
            (t_state.hdr_info.client_request.method_get_wksidx() == 
HTTP_WKSIDX_POST ||
             t_state.hdr_info.client_request.method_get_wksidx() == 
HTTP_WKSIDX_PUT)) {
   -      int         len    = 0;
   -      const char *expect = 
t_state.hdr_info.client_request.value_get(MIME_FIELD_EXPECT, MIME_LEN_EXPECT, 
&len);
   -      if ((len == HTTP_LEN_100_CONTINUE) && (strncasecmp(expect, 
HTTP_VALUE_100_CONTINUE, HTTP_LEN_100_CONTINUE) == 0)) {
   +      auto 
expect{t_state.hdr_info.client_request.value_get(static_cast<std::string_view>(MIME_FIELD_EXPECT))};
   +      if (strcasecmp(expect, std::string_view{HTTP_VALUE_100_CONTINUE,
   --
   @@ -882,11 +888,11 @@ 
HttpTransactHeaders::remove_conditional_headers(HTTPHdr *outgoing)
    void
    HttpTransactHeaders::remove_100_continue_headers(HttpTransact::State *s, 
HTTPHdr *outgoing)
    {
   -  int         len    = 0;
   -  const char *expect = 
s->hdr_info.client_request.value_get(MIME_FIELD_EXPECT, MIME_LEN_EXPECT, &len);
   +  auto 
expect{s->hdr_info.client_request.value_get(static_cast<std::string_view>(MIME_FIELD_EXPECT))};
    
   -  if ((len == HTTP_LEN_100_CONTINUE) && (strncasecmp(expect, 
HTTP_VALUE_100_CONTINUE, HTTP_LEN_100_CONTINUE) == 0)) {
   -    outgoing->field_delete(MIME_FIELD_EXPECT, MIME_LEN_EXPECT);
   +  if (strcasecmp(expect,
   ```
   
   There're so many other libswoc `strcasecmp` usages we can replace, but it's 
out of scope from this PR.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to