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

cmcfarlen 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 a0f86ddbbb Return string view from HTTPHdr methods (#12091)
a0f86ddbbb is described below

commit a0f86ddbbbe5e73c397b46b80d4b2b9cd23c936c
Author: Hiroaki Nakamura <[email protected]>
AuthorDate: Tue May 6 07:48:48 2025 +0900

    Return string view from HTTPHdr methods (#12091)
    
    * Return string_view from http_hdr_method_get
    
    * Return string_view from http_hdr_reason_get
    
    * Return string_view from HTTPHdr::method_get
    
    * Return string_view from HTTPHdr::path_get
    
    * Return string_view from HTTPHdr::query_get
    
    * Return string_view from HTTPHdr::fragment_get
    
    * Return string_view from HTTPHdr::scheme_get
    
    * Return string_view from HTTPHdr::host_get
    
    * Return string_view from HTTPHdr::reason_get
    
    * Remove uneeded .data() since swoc::bwprint supports string_view directly
    
    * Use TextView = operator
    
    * Change is_localhost in HttpTransact.cc to take string_view
---
 include/proxy/hdrs/HTTP.h              | 124 ++++++++++++++++++---------------
 src/api/InkAPI.cc                      |  12 +++-
 src/iocore/cache/CacheVC.cc            |   4 +-
 src/proxy/ControlBase.cc               |   5 +-
 src/proxy/hdrs/HTTP.cc                 |  27 ++++---
 src/proxy/hdrs/VersionConverter.cc     |  38 +++++-----
 src/proxy/http/HttpSM.cc               |  60 ++++++++--------
 src/proxy/http/HttpSessionManager.cc   |   8 +--
 src/proxy/http/HttpTransact.cc         |  75 ++++++++++----------
 src/proxy/http/HttpTransactHeaders.cc  |   5 +-
 src/proxy/http/remap/RemapProcessor.cc |  36 +++++-----
 src/proxy/http/remap/UrlRewrite.cc     |   5 +-
 src/proxy/http2/Http2Stream.cc         |   5 +-
 src/proxy/logging/LogAccess.cc         |  21 +++---
 14 files changed, 216 insertions(+), 209 deletions(-)

diff --git a/include/proxy/hdrs/HTTP.h b/include/proxy/hdrs/HTTP.h
index 22d6c45a7b..33322768c0 100644
--- a/include/proxy/hdrs/HTTP.h
+++ b/include/proxy/hdrs/HTTP.h
@@ -434,17 +434,17 @@ void http_hdr_describe(HdrHeapObjImpl *obj, bool recurse 
= true);
 
 bool http_hdr_version_set(HTTPHdrImpl *hh, const HTTPVersion &ver);
 
-const char *http_hdr_method_get(HTTPHdrImpl *hh, int *length);
-void        http_hdr_method_set(HdrHeap *heap, HTTPHdrImpl *hh, const char 
*method, int16_t method_wks_idx, int method_length,
-                                bool must_copy);
+std::string_view http_hdr_method_get(HTTPHdrImpl *hh);
+void             http_hdr_method_set(HdrHeap *heap, HTTPHdrImpl *hh, const 
char *method, int16_t method_wks_idx, int method_length,
+                                     bool must_copy);
 
 void http_hdr_url_set(HdrHeap *heap, HTTPHdrImpl *hh, URLImpl *url);
 
 // HTTPStatus             http_hdr_status_get (HTTPHdrImpl *hh);
-void        http_hdr_status_set(HTTPHdrImpl *hh, HTTPStatus status);
-const char *http_hdr_reason_get(HTTPHdrImpl *hh, int *length);
-void        http_hdr_reason_set(HdrHeap *heap, HTTPHdrImpl *hh, const char 
*value, int length, bool must_copy);
-const char *http_hdr_reason_lookup(unsigned status);
+void             http_hdr_status_set(HTTPHdrImpl *hh, HTTPStatus status);
+std::string_view http_hdr_reason_get(HTTPHdrImpl *hh);
+void             http_hdr_reason_set(HdrHeap *heap, HTTPHdrImpl *hh, const 
char *value, int length, bool must_copy);
+const char      *http_hdr_reason_lookup(unsigned status);
 
 void        http_parser_init(HTTPParser *parser);
 void        http_parser_clear(HTTPParser *parser);
@@ -516,9 +516,9 @@ public:
   HTTPVersion version_get() const;
   void        version_set(HTTPVersion version);
 
-  const char *method_get(int *length);
-  int         method_get_wksidx() const;
-  void        method_set(const char *value, int length);
+  std::string_view method_get();
+  int              method_get_wksidx() const;
+  void             method_set(const char *value, int length);
 
   URL *url_create(URL *url);
 
@@ -561,31 +561,28 @@ public:
 
   /** Get the URL path.
       This is a reference, not allocated.
-      @return A pointer to the path or @c NULL if there is no valid URL.
+      @return A string_view to the path or an empty string_view if there is no 
valid URL.
   */
-  const char *path_get(int *length ///< Storage for path length.
-  );
+  std::string_view path_get();
 
   /** 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.
+      @return A string_view to the query or an empty string_view if there is 
no valid URL.
   */
-  const char *query_get(int *length ///< Storage for query length.
-  );
+  std::string_view query_get();
 
   /** Get the URL fragment.
       This is a reference, not allocated.
-      @return A pointer to the fragment or @c NULL if there is no valid URL.
+      @return A string_view to the fragment or an empty string_view if there 
is no valid URL.
   */
-  const char *fragment_get(int *length ///< Storage for fragment length.
-  );
+  std::string_view fragment_get();
 
   /** Get the target host name.
       The length is returned in @a length if non-NULL.
       @note The results are cached so this is fast after the first call.
-      @return A pointer to the host name.
+      @return A string_view to the host name.
   */
-  const char *host_get(int *length = nullptr) const;
+  std::string_view host_get() const;
 
   /** Get the target port.
       If the target port is not found then it is adjusted to the
@@ -597,12 +594,11 @@ public:
 
   /** Get the URL scheme.
       This is a reference, not allocated.
-      @return A pointer to the scheme or @c NULL if there is no valid URL.
+      @return A string_view to the scheme or an empty string_view if there is 
no valid URL.
   */
-  const char *scheme_get(int *length ///< Storage for path length.
-  );
-  void        url_set(URL *url);
-  void        url_set(const char *str, int length);
+  std::string_view scheme_get();
+  void             url_set(URL *url);
+  void             url_set(const char *str, int length);
 
   /// Check location of target host.
   /// @return @c true if the host was in the URL, @c false otherwise.
@@ -627,8 +623,8 @@ public:
   HTTPStatus status_get() const;
   void       status_set(HTTPStatus status);
 
-  const char *reason_get(int *length);
-  void        reason_set(const char *value, int length);
+  std::string_view reason_get();
+  void             reason_set(const char *value, int length);
 
   void mark_early_data(bool flag = true) const;
   bool is_early_data() const;
@@ -774,21 +770,19 @@ HTTPHdr::_test_and_fill_target_cache() const
 /*-------------------------------------------------------------------------
   -------------------------------------------------------------------------*/
 
-inline const char *
-HTTPHdr::host_get(int *length) const
+inline std::string_view
+HTTPHdr::host_get() const
 {
   this->_test_and_fill_target_cache();
   if (m_target_in_url) {
-    return url_get()->host_get(length);
+    int  length;
+    auto host{url_get()->host_get(&length)};
+    return std::string_view{host, 
static_cast<std::string_view::size_type>(length)};
   } else if (m_host_mime) {
-    if (length)
-      *length = m_host_length;
-    return m_host_mime->m_ptr_value;
+    return std::string_view{m_host_mime->m_ptr_value, 
static_cast<std::string_view::size_type>(m_host_length)};
   }
 
-  if (length)
-    *length = 0;
-  return nullptr;
+  return std::string_view{};
 }
 
 /*-------------------------------------------------------------------------
@@ -948,13 +942,13 @@ HTTPHdr::version_set(HTTPVersion version)
 /*-------------------------------------------------------------------------
   -------------------------------------------------------------------------*/
 
-inline const char *
-HTTPHdr::method_get(int *length)
+inline std::string_view
+HTTPHdr::method_get()
 {
   ink_assert(valid());
   ink_assert(m_http->m_polarity == HTTP_TYPE_REQUEST);
 
-  return http_hdr_method_get(m_http, length);
+  return http_hdr_method_get(m_http);
 }
 
 inline int
@@ -1099,13 +1093,13 @@ HTTPHdr::status_set(HTTPStatus status)
 /*-------------------------------------------------------------------------
   -------------------------------------------------------------------------*/
 
-inline const char *
-HTTPHdr::reason_get(int *length)
+inline std::string_view
+HTTPHdr::reason_get()
 {
   ink_assert(valid());
   ink_assert(m_http->m_polarity == HTTP_TYPE_RESPONSE);
 
-  return http_hdr_reason_get(m_http, length);
+  return http_hdr_reason_get(m_http);
 }
 
 /*-------------------------------------------------------------------------
@@ -1201,32 +1195,52 @@ HTTPHdr::url_string_get_ref(int *length)
   return this->url_string_get(USE_HDR_HEAP_MAGIC, length);
 }
 
-inline const char *
-HTTPHdr::path_get(int *length)
+inline std::string_view
+HTTPHdr::path_get()
 {
   URL *url = this->url_get();
-  return url ? url->path_get(length) : nullptr;
+  if (url) {
+    int  length;
+    auto path{url->path_get(&length)};
+    return std::string_view{path, 
static_cast<std::string_view::size_type>(length)};
+  }
+  return std::string_view{};
 }
 
-inline const char *
-HTTPHdr::query_get(int *length)
+inline std::string_view
+HTTPHdr::query_get()
 {
   URL *url = this->url_get();
-  return url ? url->query_get(length) : nullptr;
+  if (url) {
+    int  length;
+    auto query{url->query_get(&length)};
+    return std::string_view{query, 
static_cast<std::string_view::size_type>(length)};
+  }
+  return std::string_view{};
 }
 
-inline const char *
-HTTPHdr::fragment_get(int *length)
+inline std::string_view
+HTTPHdr::fragment_get()
 {
   URL *url = this->url_get();
-  return url ? url->fragment_get(length) : nullptr;
+  if (url) {
+    int  length;
+    auto fragment{url->fragment_get(&length)};
+    return std::string_view{fragment, 
static_cast<std::string_view::size_type>(length)};
+  }
+  return std::string_view{};
 }
 
-inline const char *
-HTTPHdr::scheme_get(int *length)
+inline std::string_view
+HTTPHdr::scheme_get()
 {
   URL *url = this->url_get();
-  return url ? url->scheme_get(length) : nullptr;
+  if (url) {
+    int  length;
+    auto scheme{url->scheme_get(&length)};
+    return std::string_view{scheme, 
static_cast<std::string_view::size_type>(length)};
+  }
+  return std::string_view{};
 }
 
 /*-------------------------------------------------------------------------
diff --git a/src/api/InkAPI.cc b/src/api/InkAPI.cc
index 9afa069b29..18185a30d0 100644
--- a/src/api/InkAPI.cc
+++ b/src/api/InkAPI.cc
@@ -2792,7 +2792,9 @@ TSHttpHdrMethodGet(TSMBuffer bufp, TSMLoc obj, int 
*length)
   HTTPHdr h;
 
   SET_HTTP_HDR(h, bufp, obj);
-  return h.method_get(length);
+  auto method{h.method_get()};
+  *length = static_cast<int>(method.length());
+  return method.data();
 }
 
 TSReturnCode
@@ -2831,7 +2833,9 @@ TSHttpHdrHostGet(TSMBuffer bufp, TSMLoc obj, int *length)
   HTTPHdr h;
 
   SET_HTTP_HDR(h, bufp, obj);
-  return h.host_get(length);
+  auto host{h.host_get()};
+  *length = static_cast<int>(host.length());
+  return host.data();
 }
 
 TSReturnCode
@@ -2921,7 +2925,9 @@ TSHttpHdrReasonGet(TSMBuffer bufp, TSMLoc obj, int 
*length)
   HTTPHdr h;
 
   SET_HTTP_HDR(h, bufp, obj);
-  return h.reason_get(length);
+  auto reason{h.reason_get()};
+  *length = static_cast<int>(reason.length());
+  return reason.data();
 }
 
 TSReturnCode
diff --git a/src/iocore/cache/CacheVC.cc b/src/iocore/cache/CacheVC.cc
index 552402ada0..00d9487959 100644
--- a/src/iocore/cache/CacheVC.cc
+++ b/src/iocore/cache/CacheVC.cc
@@ -775,7 +775,9 @@ CacheVC::scanObject(int /* event ATS_UNUSED */, Event * /* 
e ATS_UNUSED */)
         goto Lskip;
       }
       if (!hostinfo_copied) {
-        memccpy(hname, vector.get(i)->request_get()->host_get(&hlen), 0, 500);
+        auto host{vector.get(i)->request_get()->host_get()};
+        hlen = static_cast<int>(host.length());
+        memccpy(hname, host.data(), 0, 500);
         hname[hlen] = 0;
         Dbg(dbg_ctl_cache_scan, "hostname = '%s', hostlen = %d", hname, hlen);
         hostinfo_copied = true;
diff --git a/src/proxy/ControlBase.cc b/src/proxy/ControlBase.cc
index dfc325ab03..31fafb70d6 100644
--- a/src/proxy/ControlBase.cc
+++ b/src/proxy/ControlBase.cc
@@ -486,9 +486,8 @@ MethodMod::name() const
 bool
 MethodMod::check(HttpRequestData *req) const
 {
-  int         method_len;
-  const char *method = req->hdr->method_get(&method_len);
-  return method_len >= static_cast<int>(text.size()) && 0 == 
strncasecmp(method, text.data(), text.size());
+  auto method{req->hdr->method_get()};
+  return method.length() >= text.length() && 0 == strncasecmp(method.data(), 
text.data(), text.length());
 }
 MethodMod *
 MethodMod::make(char *value, const char **)
diff --git a/src/proxy/hdrs/HTTP.cc b/src/proxy/hdrs/HTTP.cc
index 389b98097b..6c9eb63de5 100644
--- a/src/proxy/hdrs/HTTP.cc
+++ b/src/proxy/hdrs/HTTP.cc
@@ -691,22 +691,23 @@ http_hdr_version_set(HTTPHdrImpl *hh, const HTTPVersion 
&ver)
 /*-------------------------------------------------------------------------
   -------------------------------------------------------------------------*/
 
-const char *
-http_hdr_method_get(HTTPHdrImpl *hh, int *length)
+std::string_view
+http_hdr_method_get(HTTPHdrImpl *hh)
 {
   const char *str;
+  int         length;
 
   ink_assert(hh->m_polarity == HTTP_TYPE_REQUEST);
 
   if (hh->u.req.m_method_wks_idx >= 0) {
-    str     = hdrtoken_index_to_wks(hh->u.req.m_method_wks_idx);
-    *length = hdrtoken_index_to_length(hh->u.req.m_method_wks_idx);
+    str    = hdrtoken_index_to_wks(hh->u.req.m_method_wks_idx);
+    length = hdrtoken_index_to_length(hh->u.req.m_method_wks_idx);
   } else {
-    str     = hh->u.req.m_ptr_method;
-    *length = hh->u.req.m_len_method;
+    str    = hh->u.req.m_ptr_method;
+    length = hh->u.req.m_len_method;
   }
 
-  return (str);
+  return std::string_view{str, 
static_cast<std::string_view::size_type>(length)};
 }
 
 /*-------------------------------------------------------------------------
@@ -761,12 +762,11 @@ http_hdr_status_set(HTTPHdrImpl *hh, HTTPStatus status)
 /*-------------------------------------------------------------------------
   -------------------------------------------------------------------------*/
 
-const char *
-http_hdr_reason_get(HTTPHdrImpl *hh, int *length)
+std::string_view
+http_hdr_reason_get(HTTPHdrImpl *hh)
 {
   ink_assert(hh->m_polarity == HTTP_TYPE_RESPONSE);
-  *length = hh->u.resp.m_len_reason;
-  return (hh->u.resp.m_ptr_reason);
+  return std::string_view{hh->u.resp.m_ptr_reason, 
static_cast<std::string_view::size_type>(hh->u.resp.m_len_reason)};
 }
 
 /*-------------------------------------------------------------------------
@@ -1740,10 +1740,9 @@ HTTPHdr::set_url_target_from_host_field(URL *url)
       m_target_in_url = true; // it's there now.
     }
   } else {
-    int         host_len = 0;
-    const char *host     = host_get(&host_len);
+    auto host{host_get()};
 
-    url->host_set(host, host_len);
+    url->host_set(host.data(), static_cast<int>(host.length()));
     if (m_port_in_header) {
       url->port_set(m_port);
     }
diff --git a/src/proxy/hdrs/VersionConverter.cc 
b/src/proxy/hdrs/VersionConverter.cc
index 8cf0f64586..667cd31b10 100644
--- a/src/proxy/hdrs/VersionConverter.cc
+++ b/src/proxy/hdrs/VersionConverter.cc
@@ -75,10 +75,9 @@ VersionConverter::_convert_req_from_1_to_2(HTTPHdr &header) 
const
 {
   // :method
   if (MIMEField *field = header.field_find(PSEUDO_HEADER_METHOD.data(), 
PSEUDO_HEADER_METHOD.size()); field != nullptr) {
-    int         value_len;
-    const char *value = header.method_get(&value_len);
+    auto value{header.method_get()};
 
-    field->value_set(header.m_heap, header.m_mime, value, value_len);
+    field->value_set(header.m_heap, header.m_mime, value.data(), 
static_cast<int>(value.length()));
   } else {
     ink_abort("initialize HTTP/2 pseudo-headers, no :method");
     return PARSE_RESULT_ERROR;
@@ -86,11 +85,10 @@ VersionConverter::_convert_req_from_1_to_2(HTTPHdr &header) 
const
 
   // :scheme
   if (MIMEField *field = header.field_find(PSEUDO_HEADER_SCHEME.data(), 
PSEUDO_HEADER_SCHEME.size()); field != nullptr) {
-    int         value_len;
-    const char *value = header.scheme_get(&value_len);
+    auto value{header.scheme_get()};
 
-    if (value != nullptr) {
-      field->value_set(header.m_heap, header.m_mime, value, value_len);
+    if (!value.empty()) {
+      field->value_set(header.m_heap, header.m_mime, value.data(), 
static_cast<int>(value.length()));
     } else {
       field->value_set(header.m_heap, header.m_mime, URL_SCHEME_HTTPS, 
URL_LEN_HTTPS);
     }
@@ -101,18 +99,18 @@ VersionConverter::_convert_req_from_1_to_2(HTTPHdr 
&header) const
 
   // :authority
   if (MIMEField *field = header.field_find(PSEUDO_HEADER_AUTHORITY.data(), 
PSEUDO_HEADER_AUTHORITY.size()); field != nullptr) {
-    int         value_len;
-    const char *value = header.host_get(&value_len);
+    auto value{header.host_get()};
+    auto value_len{static_cast<int>(value.length())};
 
     if (header.is_port_in_header()) {
       int                   port = header.port_get();
       ts::LocalBuffer<char> buf(value_len + 8);
       char                 *host_and_port = buf.data();
-      value_len                           = snprintf(host_and_port, value_len 
+ 8, "%.*s:%d", value_len, value, port);
+      value_len                           = snprintf(host_and_port, value_len 
+ 8, "%.*s:%d", value_len, value.data(), port);
 
       field->value_set(header.m_heap, header.m_mime, host_and_port, value_len);
     } else {
-      field->value_set(header.m_heap, header.m_mime, value, value_len);
+      field->value_set(header.m_heap, header.m_mime, value.data(), value_len);
     }
     // Remove the host header field, redundant to the authority field
     // For istio/envoy, having both was causing 404 responses
@@ -124,20 +122,18 @@ VersionConverter::_convert_req_from_1_to_2(HTTPHdr 
&header) const
 
   // :path
   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         query_len = 0;
-    const char *query     = header.query_get(&query_len);
-    int         path_len  = value_len + 1;
+    auto value{header.path_get()};
+    auto query{header.query_get()};
+    int  path_len = static_cast<int>(value.length()) + 1;
 
-    ts::LocalBuffer<char> buf(value_len + 1 + 1 + 1 + query_len);
+    ts::LocalBuffer<char> buf(static_cast<int>(value.length()) + 1 + 1 + 1 + 
static_cast<int>(query.length()));
     char                 *path = buf.data();
     path[0]                    = '/';
-    memcpy(path + 1, value, value_len);
-    if (query_len > 0) {
+    memcpy(path + 1, value.data(), static_cast<int>(value.length()));
+    if (static_cast<int>(query.length()) > 0) {
       path[path_len] = '?';
-      memcpy(path + path_len + 1, query, query_len);
-      path_len += 1 + query_len;
+      memcpy(path + path_len + 1, query.data(), 
static_cast<int>(query.length()));
+      path_len += 1 + static_cast<int>(query.length());
     }
     field->value_set(header.m_heap, header.m_mime, path, path_len);
   } else {
diff --git a/src/proxy/http/HttpSM.cc b/src/proxy/http/HttpSM.cc
index 051b001386..3e41d74eef 100644
--- a/src/proxy/http/HttpSM.cc
+++ b/src/proxy/http/HttpSM.cc
@@ -4342,10 +4342,10 @@ HttpSM::check_sni_host()
 {
   // Check that the SNI and host name fields match, if it matters
   // Issue warning or mark the transaction to be terminated as necessary
-  int         host_len;
-  const char *host_name = t_state.hdr_info.client_request.host_get(&host_len);
+  auto host_name{t_state.hdr_info.client_request.host_get()};
+  auto host_len{static_cast<int>(host_name.length())};
 
-  if (host_name == nullptr || host_len == 0) {
+  if (host_name.empty()) {
     return;
   }
 
@@ -4360,8 +4360,7 @@ HttpSM::check_sni_host()
   }
 
   int host_sni_policy = t_state.http_config_param->http_host_sni_policy;
-  if (snis->would_have_actions_for(std::string{host_name, 
static_cast<size_t>(host_len)}.c_str(), netvc->get_remote_endpoint(),
-                                   host_sni_policy) &&
+  if (snis->would_have_actions_for(std::string{host_name}.c_str(), 
netvc->get_remote_endpoint(), host_sni_policy) &&
       host_sni_policy > 0) {
     // In a SNI/Host mismatch where the Host would have triggered SNI policy, 
mark the transaction
     // to be considered for rejection after the remap phase passes.  Gives the 
opportunity to conf_remap
@@ -4369,28 +4368,29 @@ HttpSM::check_sni_host()
     const char *sni_value    = snis->get_sni_server_name();
     const char *action_value = host_sni_policy == 2 ? "terminate" : "continue";
     if (!sni_value || sni_value[0] == '\0') { // No SNI
-      Warning("No SNI for TLS request with hostname %.*s action=%s", host_len, 
host_name, action_value);
-      SMDbg(dbg_ctl_ssl_sni, "No SNI for TLS request with hostname %.*s 
action=%s", host_len, host_name, action_value);
+      Warning("No SNI for TLS request with hostname %.*s action=%s", host_len, 
host_name.data(), action_value);
+      SMDbg(dbg_ctl_ssl_sni, "No SNI for TLS request with hostname %.*s 
action=%s", host_len, host_name.data(), action_value);
       if (host_sni_policy == 2) {
         swoc::bwprint(error_bw_buffer, "No SNI for TLS request: connecting to 
{} for host='{}', returning a 403",
-                      t_state.client_info.dst_addr, 
std::string_view{host_name, static_cast<size_t>(host_len)});
+                      t_state.client_info.dst_addr, host_name);
         Log::error("%s", error_bw_buffer.c_str());
         this->t_state.client_connection_allowed = false;
       }
-    } else if (strncasecmp(host_name, sni_value, host_len) != 0) { // Name 
mismatch
-      Warning("SNI/hostname mismatch sni=%s host=%.*s action=%s", sni_value, 
host_len, host_name, action_value);
-      SMDbg(dbg_ctl_ssl_sni, "SNI/hostname mismatch sni=%s host=%.*s 
action=%s", sni_value, host_len, host_name, action_value);
+    } else if (strncasecmp(host_name.data(), sni_value, host_len) != 0) { // 
Name mismatch
+      Warning("SNI/hostname mismatch sni=%s host=%.*s action=%s", sni_value, 
host_len, host_name.data(), action_value);
+      SMDbg(dbg_ctl_ssl_sni, "SNI/hostname mismatch sni=%s host=%.*s 
action=%s", sni_value, host_len, host_name.data(),
+            action_value);
       if (host_sni_policy == 2) {
         swoc::bwprint(error_bw_buffer, "SNI/hostname mismatch: connecting to 
{} for host='{}' sni='{}', returning a 403",
-                      t_state.client_info.dst_addr, 
std::string_view{host_name, static_cast<size_t>(host_len)}, sni_value);
+                      t_state.client_info.dst_addr, host_name, sni_value);
         Log::error("%s", error_bw_buffer.c_str());
         this->t_state.client_connection_allowed = false;
       }
     } else {
-      SMDbg(dbg_ctl_ssl_sni, "SNI/hostname successfully match sni=%s 
host=%.*s", sni_value, host_len, host_name);
+      SMDbg(dbg_ctl_ssl_sni, "SNI/hostname successfully match sni=%s 
host=%.*s", sni_value, host_len, host_name.data());
     }
   } else {
-    SMDbg(dbg_ctl_ssl_sni, "No SNI/hostname check configured for host=%.*s", 
host_len, host_name);
+    SMDbg(dbg_ctl_ssl_sni, "No SNI/hostname check configured for host=%.*s", 
host_len, host_name.data());
   }
 }
 
@@ -5195,9 +5195,7 @@ HttpSM::get_outbound_sni() const
 
   if (policy.empty() || policy == "host"_tv) {
     // By default the host header field value is used for the SNI.
-    int         len;
-    char const *ptr = t_state.hdr_info.server_request.host_get(&len);
-    zret.assign(ptr, len);
+    zret = t_state.hdr_info.server_request.host_get();
   } else if (_ua.get_txn() && policy == "server_name"_tv) {
     const char *server_name = snis->get_sni_server_name();
     if (server_name[0] == '\0') {
@@ -5238,9 +5236,8 @@ HttpSM::ip_allow_is_request_forbidden(const IpAllow::ACL 
&acl)
       if (this->get_request_method_wksidx() != -1) {
         result = !acl.isMethodAllowed(this->get_request_method_wksidx());
       } else {
-        int  method_str_len{};
-        auto method_str = 
t_state.hdr_info.server_request.method_get(&method_str_len);
-        result          = 
!acl.isNonstandardMethodAllowed(std::string_view(method_str, method_str_len));
+        auto method{t_state.hdr_info.server_request.method_get()};
+        result = !acl.isNonstandardMethodAllowed(method);
       }
     }
   }
@@ -5253,13 +5250,12 @@ HttpSM::ip_allow_deny_request(const IpAllow::ACL &acl)
 {
   if (dbg_ctl_ip_allow.on()) {
     ip_text_buffer ipb;
-    const char    *method_str{};
-    int            method_str_len{};
-    method_str = t_state.hdr_info.client_request.method_get(&method_str_len);
+    auto           method{t_state.hdr_info.client_request.method_get()};
 
     const char *ntop_formatted = ats_ip_ntop(this->get_server_remote_addr(), 
ipb, sizeof(ipb));
     Warning("server '%s' prohibited by ip-allow policy at line %d", 
ntop_formatted, acl.source_line());
-    SMDbg(dbg_ctl_ip_allow, "Line %d denial for '%.*s' from %s", 
acl.source_line(), method_str_len, method_str, ntop_formatted);
+    SMDbg(dbg_ctl_ip_allow, "Line %d denial for '%.*s' from %s", 
acl.source_line(), static_cast<int>(method.length()),
+          method.data(), ntop_formatted);
   }
 
   t_state.current.retry_attempts.maximize(
@@ -5693,13 +5689,12 @@ HttpSM::do_http_server_open(bool raw, bool only_direct)
     if (sni_name.length() > 0) {
       opt.set_sni_servername(sni_name.data(), sni_name.length());
     }
-    int len = 0;
     if (t_state.txn_conf->ssl_client_sni_policy != nullptr &&
         !strcmp(t_state.txn_conf->ssl_client_sni_policy, 
"verify_with_name_source")) {
       // also set sni_hostname with host header from server request in this 
policy
-      const char *host = t_state.hdr_info.server_request.host_get(&len);
-      if (host && len > 0) {
-        opt.set_sni_hostname(host, len);
+      auto host{t_state.hdr_info.server_request.host_get()};
+      if (!host.empty()) {
+        opt.set_sni_hostname(host.data(), static_cast<int>(host.length()));
       }
     }
     if (t_state.server_info.name) {
@@ -8336,7 +8331,7 @@ HttpSM::redirect_request(const char *arg_redirect_url, 
const int arg_redirect_le
   }
 
   bool valid_origHost = true;
-  int  origHost_len, origMethod_len;
+  int  origHost_len, origMethod_len{0};
   char origHost[MAXDNAME];
   char origMethod[255];
   int  origPort = 80;
@@ -8354,9 +8349,10 @@ HttpSM::redirect_request(const char *arg_redirect_url, 
const int arg_redirect_le
       valid_origHost = false;
     }
 
-    char *tmpOrigMethod = const_cast<char 
*>(t_state.hdr_info.server_request.method_get(&origMethod_len));
-    if (tmpOrigMethod) {
-      memcpy(origMethod, tmpOrigMethod, std::min(origMethod_len, 
static_cast<int>(sizeof(origMethod))));
+    auto tmpOrigMethod{t_state.hdr_info.server_request.method_get()};
+    origMethod_len = tmpOrigMethod.length();
+    if (!tmpOrigMethod.empty()) {
+      memcpy(origMethod, tmpOrigMethod.data(), std::min(origMethod_len, 
static_cast<int>(sizeof(origMethod))));
     } else {
       valid_origHost = false;
     }
diff --git a/src/proxy/http/HttpSessionManager.cc 
b/src/proxy/http/HttpSessionManager.cc
index a3177b3453..6e081ca026 100644
--- a/src/proxy/http/HttpSessionManager.cc
+++ b/src/proxy/http/HttpSessionManager.cc
@@ -98,10 +98,10 @@ ServerSessionPool::validate_host_sni(HttpSM *sm, 
NetVConnection *netvc)
       if (session_sni && session_sni[0] != '\0') {
         // TS-4468: If the connection matches, make sure the SNI server
         // name (if present) matches the request hostname
-        int         len      = 0;
-        const char *req_host = 
sm->t_state.hdr_info.server_request.host_get(&len);
-        retval               = strncasecmp(session_sni, req_host, len) == 0;
-        Dbg(dbg_ctl_http_ss, "validate_host_sni host=%*.s, sni=%s", len, 
req_host, session_sni);
+        auto req_host{sm->t_state.hdr_info.server_request.host_get()};
+        retval = strncasecmp(session_sni, req_host.data(), req_host.length()) 
== 0;
+        Dbg(dbg_ctl_http_ss, "validate_host_sni host=%*.s, sni=%s", 
static_cast<int>(req_host.length()), req_host.data(),
+            session_sni);
       }
     } else {
       retval = false;
diff --git a/src/proxy/http/HttpTransact.cc b/src/proxy/http/HttpTransact.cc
index 2a0bab4cb9..e0bc8c2214 100644
--- a/src/proxy/http/HttpTransact.cc
+++ b/src/proxy/http/HttpTransact.cc
@@ -30,6 +30,8 @@
 #include <strings.h>
 #include <cmath>
 
+using namespace std::literals;
+
 #include "proxy/http/HttpTransact.h"
 #include "proxy/http/HttpTransactHeaders.h"
 #include "proxy/http/HttpSM.h"
@@ -323,10 +325,9 @@ nextParent(HttpTransact::State *s)
 }
 
 inline static bool
-is_localhost(const char *name, int len)
+is_localhost(std::string_view name)
 {
-  static const char local[] = "127.0.0.1";
-  return (len == (sizeof(local) - 1)) && (memcmp(name, local, len) == 0);
+  return name == "127.0.0.1"sv;
 }
 
 bool
@@ -591,10 +592,9 @@ is_negative_caching_appropriate(HttpTransact::State *s)
 inline static ResolveInfo::UpstreamResolveStyle
 find_server_and_update_current_info(HttpTransact::State *s)
 {
-  int         host_len;
-  const char *host = s->hdr_info.client_request.host_get(&host_len);
+  auto host{s->hdr_info.client_request.host_get()};
 
-  if (is_localhost(host, host_len)) {
+  if (is_localhost(host)) {
     // Do not forward requests to local_host onto a parent.
     // I just wanted to do this for cop heartbeats, someone else
     // wanted it for all requests to local_host.
@@ -1056,11 +1056,10 @@ HttpTransact::EndRemapRequest(State *s)
 {
   TxnDbg(dbg_ctl_http_trans, "START HttpTransact::EndRemapRequest");
 
-  HTTPHdr    *incoming_request = &s->hdr_info.client_request;
-  int         method           = incoming_request->method_get_wksidx();
-  int         host_len;
-  const char *host = incoming_request->host_get(&host_len);
-  TxnDbg(dbg_ctl_http_trans, "EndRemapRequest host is %.*s", host_len, host);
+  HTTPHdr *incoming_request = &s->hdr_info.client_request;
+  int      method           = incoming_request->method_get_wksidx();
+  auto     host{incoming_request->host_get()};
+  TxnDbg(dbg_ctl_http_trans, "EndRemapRequest host is %.*s", 
static_cast<int>(host.length()), host.data());
   if (s->state_machine->get_ua_txn()) {
     
s->state_machine->get_ua_txn()->set_default_inactivity_timeout(HRTIME_SECONDS(s->txn_conf->default_inactivity_timeout));
   }
@@ -1165,7 +1164,7 @@ HttpTransact::EndRemapRequest(State *s)
         build_error_response(s, HTTP_STATUS_MOVED_TEMPORARILY, "Redirect For 
Explanation", "request#no_host");
         s->hdr_info.client_response.value_set(MIME_FIELD_LOCATION, 
MIME_LEN_LOCATION, redirect_url, redirect_url_len);
         // socket when there is no host. Need to handle DNS failure elsewhere.
-      } else if (host == nullptr) { /* no host */
+      } else if (host.empty()) { /* no host */
         build_error_response(s, HTTP_STATUS_BAD_REQUEST, "Host Header 
Required", "request#no_host");
         s->squid_codes.log_code = SQUID_LOG_ERR_INVALID_URL;
       } else {
@@ -1396,7 +1395,7 @@ mimefield_value_equal(MIMEField *field, const char 
*value, const int value_len)
 void
 HttpTransact::ModifyRequest(State *s)
 {
-  int              scheme, hostname_len;
+  int              scheme;
   HTTPHdr         &request      = s->hdr_info.client_request;
   static const int PORT_PADDING = 8;
 
@@ -1432,14 +1431,15 @@ HttpTransact::ModifyRequest(State *s)
   // The solution should be to move the scheme detecting logic in to
   // the header class, rather than doing it in a random bit of
   // external code.
-  const char *buf = request.host_get(&hostname_len);
+  auto buf{request.host_get()};
+  auto hostname_len{static_cast<int>(buf.length())};
   if (!request.is_target_in_url()) {
     s->hdr_info.client_req_is_server_style = true;
   }
   // Copy out buf to a hostname just in case its heap header memory is freed 
during coalescing
   // due to later HdrHeap operations
   char *hostname = static_cast<char *>(alloca(hostname_len + PORT_PADDING));
-  memcpy(hostname, buf, hostname_len);
+  memcpy(hostname, buf.data(), hostname_len);
 
   // Make clang analyzer happy. hostname is non-null iff 
request.is_target_in_url().
   ink_assert(hostname || s->hdr_info.client_req_is_server_style);
@@ -5329,15 +5329,15 @@ HttpTransact::check_request_validity(State *s, HTTPHdr 
*incoming_hdr)
     return FAILED_PROXY_AUTHORIZATION;
   }
 
-  URL        *incoming_url = incoming_hdr->url_get();
-  int         hostname_len;
-  const char *hostname = incoming_hdr->host_get(&hostname_len);
+  URL *incoming_url = incoming_hdr->url_get();
+  auto hostname{incoming_hdr->host_get()};
+  auto hostname_len{static_cast<int>(hostname.length())};
 
-  if (hostname == nullptr) {
+  if (hostname.empty()) {
     return MISSING_HOST_FIELD;
   }
 
-  if (hostname_len >= MAXDNAME || hostname_len <= 0 || memchr(hostname, '\0', 
hostname_len)) {
+  if (hostname_len >= MAXDNAME || hostname_len <= 0 || memchr(hostname.data(), 
'\0', hostname_len)) {
     return BAD_HTTP_HEADER_SYNTAX;
   }
 
@@ -5621,8 +5621,7 @@ 
HttpTransact::initialize_state_variables_from_request(State *s, HTTPHdr *obsolet
   // Temporary, until we're confident that the second argument is redundant.
   ink_assert(incoming_request == obsolete_incoming_request);
 
-  int         host_len;
-  const char *host_name = incoming_request->host_get(&host_len);
+  auto host_name{incoming_request->host_get()};
 
   // check if the request is conditional (IMS or INM)
   if (incoming_request->presence(MIME_PRESENCE_IF_MODIFIED_SINCE | 
MIME_PRESENCE_IF_NONE_MATCH)) {
@@ -5667,7 +5666,7 @@ 
HttpTransact::initialize_state_variables_from_request(State *s, HTTPHdr *obsolet
   }
 
   if (!s->server_info.name || s->redirect_info.redirect_in_process) {
-    s->server_info.name = s->arena.str_store(host_name, host_len);
+    s->server_info.name = s->arena.str_store(host_name.data(), 
static_cast<int>(host_name.length()));
     s->server_info.name_addr.load(s->server_info.name);
   }
 
@@ -5718,7 +5717,7 @@ 
HttpTransact::initialize_state_variables_from_request(State *s, HTTPHdr *obsolet
   }
   s->request_data.hdr = &s->hdr_info.client_request;
 
-  s->request_data.hostname_str = s->arena.str_store(host_name, host_len);
+  s->request_data.hostname_str = s->arena.str_store(host_name.data(), 
static_cast<int>(host_name.length()));
   ats_ip_copy(&s->request_data.src_ip, &s->client_info.src_addr);
   memset(&s->request_data.dest_ip, 0, sizeof(s->request_data.dest_ip));
   if (vc) {
@@ -6529,30 +6528,28 @@ HttpTransact::process_quick_http_filter(State *s, int 
method)
   }
 
   if (s->state_machine->get_ua_txn()) {
-    auto       &acl            = s->state_machine->get_ua_txn()->get_acl();
-    bool        deny_request   = !acl.isValid();
-    int         method_str_len = 0;
-    const char *method_str     = nullptr;
+    auto            &acl          = s->state_machine->get_ua_txn()->get_acl();
+    bool             deny_request = !acl.isValid();
+    std::string_view method_str;
 
     if (acl.isValid() && !acl.isAllowAll()) {
       if (method != -1) {
         deny_request = !acl.isMethodAllowed(method);
       } else {
-        method_str   = s->hdr_info.client_request.method_get(&method_str_len);
-        deny_request = 
!acl.isNonstandardMethodAllowed(std::string_view(method_str, method_str_len));
+        method_str   = s->hdr_info.client_request.method_get();
+        deny_request = !acl.isNonstandardMethodAllowed(method_str);
       }
     }
     if (deny_request) {
       if (dbg_ctl_ip_allow.on()) {
         ip_text_buffer ipb;
         if (method != -1) {
-          method_str     = hdrtoken_index_to_wks(method);
-          method_str_len = strlen(method_str);
-        } else if (!method_str) {
-          method_str = s->hdr_info.client_request.method_get(&method_str_len);
+          method_str = std::string_view{hdrtoken_index_to_wks(method)};
+        } else if (method_str.empty()) {
+          method_str = s->hdr_info.client_request.method_get();
         }
-        TxnDbg(dbg_ctl_ip_allow, "Line %d denial for '%.*s' from %s", 
acl.source_line(), method_str_len, method_str,
-               ats_ip_ntop(&s->client_info.src_addr.sa, ipb, sizeof(ipb)));
+        TxnDbg(dbg_ctl_ip_allow, "Line %d denial for '%.*s' from %s", 
acl.source_line(), static_cast<int>(method_str.length()),
+               method_str.data(), ats_ip_ntop(&s->client_info.src_addr.sa, 
ipb, sizeof(ipb)));
       }
       s->client_connection_allowed = false;
     }
@@ -7944,10 +7941,8 @@ HttpTransact::build_response(State *s, HTTPHdr 
*base_response, HTTPHdr *outgoing
 
   // When converting a response, only set a reason phrase if one was not 
already
   // set via some explicit call above.
-  char const *reason_phrase_for_convert  = nullptr;
-  int         outgoing_reason_phrase_len = 0;
-  char const *outgoing_reason_phrase     = 
outgoing_response->reason_get(&outgoing_reason_phrase_len);
-  if (outgoing_reason_phrase == nullptr || outgoing_reason_phrase_len == 0) {
+  char const *reason_phrase_for_convert = nullptr;
+  if (outgoing_response->reason_get().empty()) {
     reason_phrase_for_convert = reason_phrase;
   }
   HttpTransactHeaders::convert_response(outgoing_version, outgoing_response, 
reason_phrase_for_convert);
diff --git a/src/proxy/http/HttpTransactHeaders.cc 
b/src/proxy/http/HttpTransactHeaders.cc
index 7f730d7db1..504f0d6d3d 100644
--- a/src/proxy/http/HttpTransactHeaders.cc
+++ b/src/proxy/http/HttpTransactHeaders.cc
@@ -439,10 +439,9 @@ HttpTransactHeaders::generate_and_set_squid_codes(HTTPHdr 
*header, char *via_str
       hit_miss_code = SQUID_HIT_RESERVED;
     }
   } else {
-    int         reason_len;
-    const char *reason = header->reason_get(&reason_len);
+    auto reason{header->reason_get()};
 
-    if (reason != nullptr && reason_len >= 24 && reason[0] == '!' && reason[1] 
== SQUID_HIT_RESERVED) {
+    if (!reason.empty() && reason.length() >= 24 && reason[0] == '!' && 
reason[1] == SQUID_HIT_RESERVED) {
       hit_miss_code = SQUID_HIT_RESERVED;
       // its a miss in the cache. find out why.
     } else if (via_string[VIA_DETAIL_CACHE_LOOKUP] == VIA_DETAIL_MISS_EXPIRED) 
{
diff --git a/src/proxy/http/remap/RemapProcessor.cc 
b/src/proxy/http/remap/RemapProcessor.cc
index 1e54c5eb67..c110133e30 100644
--- a/src/proxy/http/remap/RemapProcessor.cc
+++ b/src/proxy/http/remap/RemapProcessor.cc
@@ -23,6 +23,8 @@
 
 #include "proxy/http/remap/RemapProcessor.h"
 
+using namespace std::literals;
+
 RemapProcessor remapProcessor;
 
 namespace
@@ -41,14 +43,12 @@ bool
 RemapProcessor::setup_for_remap(HttpTransact::State *s, UrlRewrite *table)
 {
   Dbg(dbg_ctl_url_rewrite, "setting up for remap: %p", s);
-  URL        *request_url    = nullptr;
-  bool        mapping_found  = false;
-  HTTPHdr    *request_header = &s->hdr_info.client_request;
-  char      **redirect_url   = &s->remap_redirect;
-  const char *request_host;
-  int         request_host_len;
-  int         request_port;
-  bool        proxy_request = false;
+  URL     *request_url    = nullptr;
+  bool     mapping_found  = false;
+  HTTPHdr *request_header = &s->hdr_info.client_request;
+  char   **redirect_url   = &s->remap_redirect;
+  int      request_port;
+  bool     proxy_request = false;
 
   s->reverse_proxy = table->reverse_proxy;
   s->url_map.set(s->hdr_info.client_request.m_heap);
@@ -69,13 +69,12 @@ RemapProcessor::setup_for_remap(HttpTransact::State *s, 
UrlRewrite *table)
     return false;
   }
 
-  request_host  = request_header->host_get(&request_host_len);
+  auto request_host{request_header->host_get()};
   request_port  = request_header->port_get();
   proxy_request = request_header->is_target_in_url() || !s->reverse_proxy;
   // Default to empty host.
-  if (!request_host) {
-    request_host     = "";
-    request_host_len = 0;
+  if (request_host.empty()) {
+    request_host = ""sv;
   }
 
   Dbg(dbg_ctl_url_rewrite, "[lookup] attempting %s lookup", proxy_request ? 
"proxy" : "normal");
@@ -83,8 +82,8 @@ RemapProcessor::setup_for_remap(HttpTransact::State *s, 
UrlRewrite *table)
   if (table->num_rules_forward_with_recv_port) {
     Dbg(dbg_ctl_url_rewrite, "[lookup] forward mappings with recv port found; 
Using recv port %d",
         s->client_info.dst_addr.host_order_port());
-    if (table->forwardMappingWithRecvPortLookup(request_url, 
s->client_info.dst_addr.host_order_port(), request_host,
-                                                request_host_len, s->url_map)) 
{
+    if (table->forwardMappingWithRecvPortLookup(request_url, 
s->client_info.dst_addr.host_order_port(), request_host.data(),
+                                                
static_cast<int>(request_host.length()), s->url_map)) {
       Dbg(dbg_ctl_url_rewrite, "Found forward mapping with recv port");
       mapping_found = true;
     } else if (table->num_rules_forward == 0) {
@@ -95,13 +94,14 @@ RemapProcessor::setup_for_remap(HttpTransact::State *s, 
UrlRewrite *table)
   }
 
   if (!mapping_found) {
-    mapping_found = table->forwardMappingLookup(request_url, request_port, 
request_host, request_host_len, s->url_map);
+    mapping_found = table->forwardMappingLookup(request_url, request_port, 
request_host.data(),
+                                                
static_cast<int>(request_host.length()), s->url_map);
   }
 
   // If no rules match and we have a host, check empty host rules since
   // they function as default rules for server requests.
   // If there's no host, we've already done this.
-  if (!mapping_found && table->nohost_rules && request_host_len) {
+  if (!mapping_found && table->nohost_rules && !request_host.empty()) {
     Dbg(dbg_ctl_url_rewrite, "[lookup] nothing matched");
     mapping_found = table->forwardMappingLookup(request_url, 0, "", 0, 
s->url_map);
   }
@@ -110,8 +110,8 @@ RemapProcessor::setup_for_remap(HttpTransact::State *s, 
UrlRewrite *table)
 
     // Save this information for later
     // @amc: why is this done only for requests without a host in the URL?
-    s->hh_info.host_len     = request_host_len;
-    s->hh_info.request_host = request_host;
+    s->hh_info.host_len     = static_cast<int>(request_host.length());
+    s->hh_info.request_host = request_host.data();
     s->hh_info.request_port = request_port;
 
     if (mapping_found) {
diff --git a/src/proxy/http/remap/UrlRewrite.cc 
b/src/proxy/http/remap/UrlRewrite.cc
index 10f35ae24c..8ddb9e8e8e 100644
--- a/src/proxy/http/remap/UrlRewrite.cc
+++ b/src/proxy/http/remap/UrlRewrite.cc
@@ -473,9 +473,8 @@ UrlRewrite::PerformACLFiltering(HttpTransact::State *s, 
const url_mapping *const
         } else if (!rp->nonstandard_methods.empty()) {
           method_matches = false;
         } else {
-          int         method_str_len;
-          const char *method_str = 
s->hdr_info.client_request.method_get(&method_str_len);
-          method_matches         = 
rp->nonstandard_methods.count(std::string(method_str, method_str_len));
+          auto method{s->hdr_info.client_request.method_get()};
+          method_matches = rp->nonstandard_methods.count(std::string{method});
         }
       } else {
         // No method specified, therefore all match.
diff --git a/src/proxy/http2/Http2Stream.cc b/src/proxy/http2/Http2Stream.cc
index 711301d025..28444b2652 100644
--- a/src/proxy/http2/Http2Stream.cc
+++ b/src/proxy/http2/Http2Stream.cc
@@ -316,9 +316,8 @@ Http2Stream::send_headers(Http2ConnectionState & /* cstate 
ATS_UNUSED */)
 
     if (_receive_header.type_get() == HTTP_TYPE_REQUEST) {
       // Check whether the request uses CONNECT method
-      int         method_len;
-      const char *method = _receive_header.method_get(&method_len);
-      if (method_len == HTTP_LEN_CONNECT && strncmp(method, 
HTTP_METHOD_CONNECT, HTTP_LEN_CONNECT) == 0) {
+      auto method{_receive_header.method_get()};
+      if (method == std::string_view{HTTP_METHOD_CONNECT, 
static_cast<std::string_view::size_type>(HTTP_LEN_CONNECT)}) {
         this->_is_tunneling = true;
       }
     }
diff --git a/src/proxy/logging/LogAccess.cc b/src/proxy/logging/LogAccess.cc
index c5eefe748e..7dd3250b2a 100644
--- a/src/proxy/logging/LogAccess.cc
+++ b/src/proxy/logging/LogAccess.cc
@@ -89,7 +89,9 @@ LogAccess::init()
 
     m_client_req_url_canon_str =
       Encoding::escapify_url(&m_arena, m_client_req_url_str, 
m_client_req_url_len, &m_client_req_url_canon_len);
-    m_client_req_url_path_str = 
m_client_request->path_get(&m_client_req_url_path_len);
+    auto path{m_client_request->path_get()};
+    m_client_req_url_path_str = path.data();
+    m_client_req_url_path_len = static_cast<int>(path.length());
   }
 
   if (hdr->client_response.valid()) {
@@ -110,7 +112,9 @@ LogAccess::init()
         
LogUtils::remove_content_type_attributes(m_proxy_resp_content_type_str, 
&m_proxy_resp_content_type_len);
       }
     }
-    m_proxy_resp_reason_phrase_str = const_cast<char 
*>(m_proxy_response->reason_get(&m_proxy_resp_reason_phrase_len));
+    auto reason{m_proxy_response->reason_get()};
+    m_proxy_resp_reason_phrase_str = const_cast<char *>(reason.data());
+    m_proxy_resp_reason_phrase_len = static_cast<int>(reason.length());
   }
   if (hdr->server_request.valid()) {
     m_proxy_request = &(hdr->server_request);
@@ -1777,25 +1781,24 @@ LogAccess::marshal_client_req_timestamp_ms(char *buf)
 int
 LogAccess::marshal_client_req_http_method(char *buf)
 {
-  char *str  = nullptr;
-  int   alen = 0;
-  int   plen = INK_MIN_ALIGN;
+  std::string_view str;
+  int              plen = INK_MIN_ALIGN;
 
   if (m_client_request) {
-    str = const_cast<char *>(m_client_request->method_get(&alen));
+    str = m_client_request->method_get();
 
     // calculate the padded length only if the actual length
     // is not zero. We don't want the padded length to be zero
     // because marshal_mem should write the DEFAULT_STR to the
     // buffer if str is nil, and we need room for this.
     //
-    if (alen) {
-      plen = round_strlen(alen + 1); // +1 for trailing 0
+    if (!str.empty()) {
+      plen = round_strlen(static_cast<int>(str.length()) + 1); // +1 for 
trailing 0
     }
   }
 
   if (buf) {
-    marshal_mem(buf, str, alen, plen);
+    marshal_mem(buf, str.data(), static_cast<int>(str.length()), plen);
   }
   return plen;
 }


Reply via email to