trafficserver-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dra...@apache.org
Subject [trafficserver] branch master updated: Cleanup: remove ts::ConstBuffer from ink_inet. This turns out to have a lot of tentacles all over.
Date Fri, 06 Oct 2017 16:02:08 GMT
This is an automated email from the ASF dual-hosted git repository.

dragon 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 a5366d7  Cleanup: remove ts::ConstBuffer from ink_inet. This turns out to have a lot of tentacles all over.
a5366d7 is described below

commit a5366d79fda04dc79cc78d06ab5b4b054baf943b
Author: Alan M. Carroll <amc@apache.org>
AuthorDate: Sun Sep 24 17:45:23 2017 -0500

    Cleanup: remove ts::ConstBuffer from ink_inet.
    This turns out to have a lot of tentacles all over.
---
 example/ssl_preaccept/ssl_preaccept.cc             | 22 ++---
 iocore/hostdb/P_HostDBProcessor.h                  |  1 +
 iocore/net/I_NetVConnection.h                      | 12 +--
 iocore/net/NetVConnection.cc                       |  4 +-
 iocore/net/P_SSLNetVConnection.h                   |  6 +-
 iocore/net/P_UnixNetVConnection.h                  |  4 +-
 iocore/net/SSLNetVConnection.cc                    | 21 +++--
 iocore/net/UnixNetVConnection.cc                   | 18 ++---
 lib/records/RecHttp.cc                             | 30 +++----
 lib/ts/MemView.h                                   | 17 ++++
 lib/ts/ink_inet.cc                                 | 93 +++++++++++-----------
 lib/ts/ink_inet.h                                  | 51 ++++++------
 lib/ts/ink_res_init.cc                             |  2 +-
 lib/ts/string_view.h                               | 18 +++++
 lib/ts/unit-tests/test_layout.cc                   |  3 +
 mgmt/LocalManager.cc                               |  1 +
 .../ssl_cert_loader/ssl-cert-loader.cc             | 18 ++---
 proxy/InkAPI.cc                                    | 14 ++--
 proxy/ProxyClientSession.h                         |  4 +-
 proxy/ProxyClientTransaction.h                     |  4 +-
 proxy/hdrs/HTTP.cc                                 | 11 +--
 proxy/hdrs/URL.cc                                  | 15 +---
 proxy/hdrs/URL.h                                   |  4 +-
 proxy/http/HttpSM.cc                               | 29 ++++---
 proxy/http/HttpSM.h                                |  6 +-
 proxy/http/HttpServerSession.h                     |  4 +-
 proxy/http/HttpTransactHeaders.cc                  | 37 +++++----
 proxy/http/HttpTransactHeaders.h                   |  2 +-
 proxy/http2/Http2ClientSession.h                   |  8 +-
 proxy/logging/LogField.h                           |  1 +
 proxy/logging/LogHost.cc                           |  6 +-
 31 files changed, 244 insertions(+), 222 deletions(-)

diff --git a/example/ssl_preaccept/ssl_preaccept.cc b/example/ssl_preaccept/ssl_preaccept.cc
index 925a28d..4bc822c 100644
--- a/example/ssl_preaccept/ssl_preaccept.cc
+++ b/example/ssl_preaccept/ssl_preaccept.cc
@@ -51,17 +51,16 @@ IpRangeQueue ClientBlindTunnelIp;
 Configuration Config; // global configuration
 
 void
-Parse_Addr_String(ts::ConstBuffer const &text, IpRange &range)
+Parse_Addr_String(ts::string_view const &text, IpRange &range)
 {
   IpAddr newAddr;
-  std::string textstr(text._ptr, text._size);
   // Is there a hyphen?
-  size_t hyphen_pos = textstr.find('-');
-  if (hyphen_pos != std::string::npos) {
-    std::string addr1 = textstr.substr(0, hyphen_pos);
-    std::string addr2 = textstr.substr(hyphen_pos + 1);
-    range.first.load(ts::ConstBuffer(addr1.c_str(), addr1.length()));
-    range.second.load(ts::ConstBuffer(addr2.c_str(), addr2.length()));
+  size_t hyphen_pos = text.find('-');
+  if (hyphen_pos != ts::string_view::npos) {
+    ts::string_view addr1 = text.substr(0, hyphen_pos);
+    ts::string_view addr2 = text.substr(hyphen_pos + 1);
+    range.first.load(addr1);
+    range.second.load(addr2);
   } else { // Assume it is a single address
     newAddr.load(text);
     range.first  = newAddr;
@@ -77,13 +76,14 @@ Load_Config_Value(Value const &parent, const char *name, IpRangeQueue &addrs)
   std::string zret;
   IpRange ipRange;
   if (v.isLiteral()) {
-    Parse_Addr_String(v.getText(), ipRange);
+    auto txt = v.getText();
+    Parse_Addr_String(ts::string_view(txt._ptr, txt._size), ipRange);
     addrs.push_back(ipRange);
   } else if (v.isContainer()) {
     size_t i;
     for (i = 0; i < v.childCount(); i++) {
-      std::string val_str(v[i].getText()._ptr, v[i].getText()._size);
-      Parse_Addr_String(v[i].getText(), ipRange);
+      auto txt = v[i].getText();
+      Parse_Addr_String(ts::string_view(txt._ptr, txt._size), ipRange);
       addrs.push_back(ipRange);
     }
   }
diff --git a/iocore/hostdb/P_HostDBProcessor.h b/iocore/hostdb/P_HostDBProcessor.h
index 4709244..d4d6b46 100644
--- a/iocore/hostdb/P_HostDBProcessor.h
+++ b/iocore/hostdb/P_HostDBProcessor.h
@@ -29,6 +29,7 @@
 #define _P_HostDBProcessor_h_
 
 #include "I_HostDBProcessor.h"
+#include <ts/TsBuffer.h>
 
 //
 // Data
diff --git a/iocore/net/I_NetVConnection.h b/iocore/net/I_NetVConnection.h
index 7b97d6d..12b1448 100644
--- a/iocore/net/I_NetVConnection.h
+++ b/iocore/net/I_NetVConnection.h
@@ -33,7 +33,7 @@
 #include "I_IOBuffer.h"
 #include "I_Socks.h"
 #include <ts/apidefs.h>
-#include <ts/MemView.h>
+#include <ts/string_view.h>
 
 #define CONNECT_SUCCESS 1
 #define CONNECT_FAILURE 0
@@ -202,7 +202,7 @@ struct NetVCOptions {
     IpEndpoint ip;
 
     // Literal IPv4 and IPv6 addresses are not permitted in "HostName".(rfc6066#section-3)
-    if (name && len && ats_ip_pton(ts::ConstBuffer(name, len), &ip) != 0) {
+    if (name && len && ats_ip_pton(ts::string_view(name, len), &ip) != 0) {
       sni_servername = ats_strndup(name, len);
     } else {
       sni_servername = nullptr;
@@ -236,9 +236,9 @@ struct NetVCOptions {
     return *this;
   }
 
-  ts::StringView get_family_string() const;
+  ts::string_view get_family_string() const;
 
-  ts::StringView get_proto_string() const;
+  ts::string_view get_proto_string() const;
 
   /// @name Debugging
   //@{
@@ -629,13 +629,13 @@ public:
   }
 
   virtual int
-  populate_protocol(ts::StringView *results, int n) const
+  populate_protocol(ts::string_view *results, int n) const
   {
     return 0;
   }
 
   virtual const char *
-  protocol_contains(ts::StringView prefix) const
+  protocol_contains(ts::string_view prefix) const
   {
     return nullptr;
   }
diff --git a/iocore/net/NetVConnection.cc b/iocore/net/NetVConnection.cc
index 68a9507..de21160 100644
--- a/iocore/net/NetVConnection.cc
+++ b/iocore/net/NetVConnection.cc
@@ -45,7 +45,7 @@ NetVConnection::cancel_OOB()
   return;
 }
 
-ts::StringView
+ts::string_view
 NetVCOptions::get_proto_string() const
 {
   switch (ip_proto) {
@@ -59,7 +59,7 @@ NetVCOptions::get_proto_string() const
   return nullptr;
 }
 
-ts::StringView
+ts::string_view
 NetVCOptions::get_family_string() const
 {
   switch (ip_family) {
diff --git a/iocore/net/P_SSLNetVConnection.h b/iocore/net/P_SSLNetVConnection.h
index 9fcffb1..125d3c8 100644
--- a/iocore/net/P_SSLNetVConnection.h
+++ b/iocore/net/P_SSLNetVConnection.h
@@ -280,8 +280,8 @@ public:
     return ssl ? SSL_get_cipher_name(ssl) : nullptr;
   }
 
-  int populate_protocol(ts::StringView *results, int n) const override;
-  const char *protocol_contains(ts::StringView tag) const override;
+  int populate_protocol(ts::string_view *results, int n) const override;
+  const char *protocol_contains(ts::string_view tag) const override;
 
   /**
    * Populate the current object based on the socket information in in the
@@ -304,7 +304,7 @@ public:
   SSLNetVConnection &operator=(const SSLNetVConnection &) = delete;
 
 private:
-  ts::StringView map_tls_protocol_to_tag(const char *proto_string) const;
+  ts::string_view map_tls_protocol_to_tag(const char *proto_string) const;
   bool update_rbio(bool move_to_socket);
 
   bool sslHandShakeComplete        = false;
diff --git a/iocore/net/P_UnixNetVConnection.h b/iocore/net/P_UnixNetVConnection.h
index 0b72760..513bfd8 100644
--- a/iocore/net/P_UnixNetVConnection.h
+++ b/iocore/net/P_UnixNetVConnection.h
@@ -175,8 +175,8 @@ public:
   /////////////////////////////////////////////////////////////////
   UnixNetVConnection();
 
-  int populate_protocol(ts::StringView *results, int n) const override;
-  const char *protocol_contains(ts::StringView tag) const override;
+  int populate_protocol(ts::string_view *results, int n) const override;
+  const char *protocol_contains(ts::string_view tag) const override;
 
   // noncopyable
   UnixNetVConnection(const NetVConnection &) = delete;
diff --git a/iocore/net/SSLNetVConnection.cc b/iocore/net/SSLNetVConnection.cc
index 732914b..93f33e8 100644
--- a/iocore/net/SSLNetVConnection.cc
+++ b/iocore/net/SSLNetVConnection.cc
@@ -1597,13 +1597,10 @@ SSLNetVConnection::populate(Connection &con, Continuation *c, void *arg)
   return EVENT_DONE;
 }
 
-ts::StringView
+ts::string_view
 SSLNetVConnection::map_tls_protocol_to_tag(const char *proto_string) const
 {
-  // tag to use if something goes wrong with fetching the TLS protocol string.
-  static constexpr ts::StringView UNKNOWN("tls/?.?", ts::StringView::literal);
-
-  ts::StringView retval{UNKNOWN}; // return this if the protocol lookup doesn't work.
+  ts::string_view retval{"tls/?.?"_sv}; // return this if the protocol lookup doesn't work.
 
   if (proto_string) {
     // openSSL guarantees the case of the protocol string.
@@ -1632,12 +1629,12 @@ SSLNetVConnection::map_tls_protocol_to_tag(const char *proto_string) const
 }
 
 int
-SSLNetVConnection::populate_protocol(ts::StringView *results, int n) const
+SSLNetVConnection::populate_protocol(ts::string_view *results, int n) const
 {
   int retval = 0;
   if (n > retval) {
     results[retval] = map_tls_protocol_to_tag(getSSLProtocol());
-    if (results[retval]) {
+    if (!results[retval].empty()) {
       ++retval;
     }
     if (n > retval) {
@@ -1648,12 +1645,12 @@ SSLNetVConnection::populate_protocol(ts::StringView *results, int n) const
 }
 
 const char *
-SSLNetVConnection::protocol_contains(ts::StringView prefix) const
+SSLNetVConnection::protocol_contains(ts::string_view prefix) const
 {
-  const char *retval = nullptr;
-  ts::StringView tag = map_tls_protocol_to_tag(getSSLProtocol());
-  if (prefix.size() <= tag.size() && strncmp(tag.ptr(), prefix.ptr(), prefix.size()) == 0) {
-    retval = tag.ptr();
+  const char *retval  = nullptr;
+  ts::string_view tag = map_tls_protocol_to_tag(getSSLProtocol());
+  if (prefix.size() <= tag.size() && strncmp(tag.data(), prefix.data(), prefix.size()) == 0) {
+    retval = tag.data();
   } else {
     retval = super::protocol_contains(prefix);
   }
diff --git a/iocore/net/UnixNetVConnection.cc b/iocore/net/UnixNetVConnection.cc
index 63d5ba0..a4c7769 100644
--- a/iocore/net/UnixNetVConnection.cc
+++ b/iocore/net/UnixNetVConnection.cc
@@ -1495,15 +1495,15 @@ UnixNetVConnection::remove_from_active_queue()
 }
 
 int
-UnixNetVConnection::populate_protocol(ts::StringView *results, int n) const
+UnixNetVConnection::populate_protocol(ts::string_view *results, int n) const
 {
   int retval = 0;
   if (n > retval) {
-    if (!(results[retval] = options.get_proto_string()).isEmpty()) {
+    if (!(results[retval] = options.get_proto_string()).empty()) {
       ++retval;
     }
     if (n > retval) {
-      if (!(results[retval] = options.get_family_string()).isEmpty()) {
+      if (!(results[retval] = options.get_family_string()).empty()) {
         ++retval;
       }
     }
@@ -1512,14 +1512,14 @@ UnixNetVConnection::populate_protocol(ts::StringView *results, int n) const
 }
 
 const char *
-UnixNetVConnection::protocol_contains(ts::StringView tag) const
+UnixNetVConnection::protocol_contains(ts::string_view tag) const
 {
-  ts::StringView retval = options.get_proto_string();
-  if (!tag.isNoCasePrefixOf(retval)) { // didn't match IP level, check TCP level
+  ts::string_view retval = options.get_proto_string();
+  if (!IsNoCasePrefixOf(tag, retval)) { // didn't match IP level, check TCP level
     retval = options.get_family_string();
-    if (!tag.isNoCasePrefixOf(retval)) { // no match here either, return empty.
-      retval.clear();
+    if (!IsNoCasePrefixOf(tag, retval)) { // no match here either, return empty.
+      ink_zero(retval);
     }
   }
-  return retval.ptr();
+  return retval.data();
 }
diff --git a/lib/records/RecHttp.cc b/lib/records/RecHttp.cc
index ade370e..61b7541 100644
--- a/lib/records/RecHttp.cc
+++ b/lib/records/RecHttp.cc
@@ -36,10 +36,10 @@ SessionProtocolNameRegistry globalSessionProtocolNameRegistry;
    These are also used for NPN setup.
 */
 
-const char *const TS_ALPN_PROTOCOL_HTTP_0_9 = IP_PROTO_TAG_HTTP_0_9.ptr();
-const char *const TS_ALPN_PROTOCOL_HTTP_1_0 = IP_PROTO_TAG_HTTP_1_0.ptr();
-const char *const TS_ALPN_PROTOCOL_HTTP_1_1 = IP_PROTO_TAG_HTTP_1_1.ptr();
-const char *const TS_ALPN_PROTOCOL_HTTP_2_0 = IP_PROTO_TAG_HTTP_2_0.ptr();
+const char *const TS_ALPN_PROTOCOL_HTTP_0_9 = IP_PROTO_TAG_HTTP_0_9.data();
+const char *const TS_ALPN_PROTOCOL_HTTP_1_0 = IP_PROTO_TAG_HTTP_1_0.data();
+const char *const TS_ALPN_PROTOCOL_HTTP_1_1 = IP_PROTO_TAG_HTTP_1_1.data();
+const char *const TS_ALPN_PROTOCOL_HTTP_2_0 = IP_PROTO_TAG_HTTP_2_0.data();
 
 const char *const TS_ALPN_PROTOCOL_GROUP_HTTP  = "http";
 const char *const TS_ALPN_PROTOCOL_GROUP_HTTP2 = "http2";
@@ -47,14 +47,14 @@ const char *const TS_ALPN_PROTOCOL_GROUP_HTTP2 = "http2";
 const char *const TS_PROTO_TAG_HTTP_1_0 = TS_ALPN_PROTOCOL_HTTP_1_0;
 const char *const TS_PROTO_TAG_HTTP_1_1 = TS_ALPN_PROTOCOL_HTTP_1_1;
 const char *const TS_PROTO_TAG_HTTP_2_0 = TS_ALPN_PROTOCOL_HTTP_2_0;
-const char *const TS_PROTO_TAG_TLS_1_3  = IP_PROTO_TAG_TLS_1_3.ptr();
-const char *const TS_PROTO_TAG_TLS_1_2  = IP_PROTO_TAG_TLS_1_2.ptr();
-const char *const TS_PROTO_TAG_TLS_1_1  = IP_PROTO_TAG_TLS_1_1.ptr();
-const char *const TS_PROTO_TAG_TLS_1_0  = IP_PROTO_TAG_TLS_1_0.ptr();
-const char *const TS_PROTO_TAG_TCP      = IP_PROTO_TAG_TCP.ptr();
-const char *const TS_PROTO_TAG_UDP      = IP_PROTO_TAG_UDP.ptr();
-const char *const TS_PROTO_TAG_IPV4     = IP_PROTO_TAG_IPV4.ptr();
-const char *const TS_PROTO_TAG_IPV6     = IP_PROTO_TAG_IPV6.ptr();
+const char *const TS_PROTO_TAG_TLS_1_3  = IP_PROTO_TAG_TLS_1_3.data();
+const char *const TS_PROTO_TAG_TLS_1_2  = IP_PROTO_TAG_TLS_1_2.data();
+const char *const TS_PROTO_TAG_TLS_1_1  = IP_PROTO_TAG_TLS_1_1.data();
+const char *const TS_PROTO_TAG_TLS_1_0  = IP_PROTO_TAG_TLS_1_0.data();
+const char *const TS_PROTO_TAG_TCP      = IP_PROTO_TAG_TCP.data();
+const char *const TS_PROTO_TAG_UDP      = IP_PROTO_TAG_UDP.data();
+const char *const TS_PROTO_TAG_IPV4     = IP_PROTO_TAG_IPV4.data();
+const char *const TS_PROTO_TAG_IPV6     = IP_PROTO_TAG_IPV6.data();
 
 InkHashTable *TSProtoTags;
 
@@ -386,11 +386,11 @@ HttpProxyPort::processOptions(const char *opts)
 
   if (af_set_p) {
     if (in_ip_set_p && m_family != m_inbound_ip.family()) {
-      ts::StringView iname{ats_ip_family_name(m_inbound_ip.family())};
-      ts::StringView fname{ats_ip_family_name(m_family)};
+      ts::string_view iname{ats_ip_family_name(m_inbound_ip.family())};
+      ts::string_view fname{ats_ip_family_name(m_family)};
       Warning("Invalid port descriptor '%s' - the inbound adddress family [%.*s] is not the same type as the explicit family value "
               "[%.*s]",
-              opts, static_cast<int>(iname.size()), iname.ptr(), static_cast<int>(fname.size()), fname.ptr());
+              opts, static_cast<int>(iname.size()), iname.data(), static_cast<int>(fname.size()), fname.data());
       zret = false;
     }
   } else if (in_ip_set_p) {
diff --git a/lib/ts/MemView.h b/lib/ts/MemView.h
index 1925bc7..1e31968 100644
--- a/lib/ts/MemView.h
+++ b/lib/ts/MemView.h
@@ -33,6 +33,7 @@
 #include <memory.h>
 #include <algorithm>
 #include <string>
+#include <ts/string_view.h>
 
 /// Apache Traffic Server commons.
 namespace ts
@@ -344,6 +345,10 @@ public:
                        const char *end    ///< First byte not in the view.
                        );
 
+  /** Construct from standard string view.
+   */
+  constexpr StringView(ts::string_view const &that);
+
   /** Constructor from literal string.
 
       Construct directly from a literal string. This avoids a call to :c strlen and therefore is
@@ -388,6 +393,9 @@ public:
   /// @internal Not all compilers make @c std::string methods called @c constexpr
   StringView(std::string const &str);
 
+  /// Convert to standard string view.
+  operator ts::string_view() const;
+
   /** Equality.
 
       This is effectively a pointer comparison, buffer contents are not compared.
@@ -937,6 +945,15 @@ template <size_t N> constexpr StringView::StringView(const char (&s)[N], array_t
 {
 }
 
+inline constexpr StringView::StringView(ts::string_view const &that) : _ptr(that.data()), _size(that.size())
+{
+}
+
+inline StringView::operator ts::string_view() const
+{
+  return {_ptr, _size};
+}
+
 inline void StringView::initDelimiterSet(std::bitset<256> &set)
 {
   set.reset();
diff --git a/lib/ts/ink_inet.cc b/lib/ts/ink_inet.cc
index d32086d..e2f033f 100644
--- a/lib/ts/ink_inet.cc
+++ b/lib/ts/ink_inet.cc
@@ -29,21 +29,22 @@
 #include "ts/ink_assert.h"
 #include "ts/TestBox.h"
 #include <fstream>
+#include <ts/MemView.h>
 
 IpAddr const IpAddr::INVALID;
 
-const ts::StringView IP_PROTO_TAG_IPV4("ipv4", ts::StringView::literal);
-const ts::StringView IP_PROTO_TAG_IPV6("ipv6", ts::StringView::literal);
-const ts::StringView IP_PROTO_TAG_UDP("udp", ts::StringView::literal);
-const ts::StringView IP_PROTO_TAG_TCP("tcp", ts::StringView::literal);
-const ts::StringView IP_PROTO_TAG_TLS_1_0("tls/1.0", ts::StringView::literal);
-const ts::StringView IP_PROTO_TAG_TLS_1_1("tls/1.1", ts::StringView::literal);
-const ts::StringView IP_PROTO_TAG_TLS_1_2("tls/1.2", ts::StringView::literal);
-const ts::StringView IP_PROTO_TAG_TLS_1_3("tls/1.3", ts::StringView::literal);
-const ts::StringView IP_PROTO_TAG_HTTP_0_9("http/0.9", ts::StringView::literal);
-const ts::StringView IP_PROTO_TAG_HTTP_1_0("http/1.0", ts::StringView::literal);
-const ts::StringView IP_PROTO_TAG_HTTP_1_1("http/1.1", ts::StringView::literal);
-const ts::StringView IP_PROTO_TAG_HTTP_2_0("h2", ts::StringView::literal); // HTTP/2 over TLS
+const ts::string_view IP_PROTO_TAG_IPV4("ipv4"_sv);
+const ts::string_view IP_PROTO_TAG_IPV6("ipv6"_sv);
+const ts::string_view IP_PROTO_TAG_UDP("udp"_sv);
+const ts::string_view IP_PROTO_TAG_TCP("tcp"_sv);
+const ts::string_view IP_PROTO_TAG_TLS_1_0("tls/1.0"_sv);
+const ts::string_view IP_PROTO_TAG_TLS_1_1("tls/1.1"_sv);
+const ts::string_view IP_PROTO_TAG_TLS_1_2("tls/1.2"_sv);
+const ts::string_view IP_PROTO_TAG_TLS_1_3("tls/1.3"_sv);
+const ts::string_view IP_PROTO_TAG_HTTP_0_9("http/0.9"_sv);
+const ts::string_view IP_PROTO_TAG_HTTP_1_0("http/1.0"_sv);
+const ts::string_view IP_PROTO_TAG_HTTP_1_1("http/1.1"_sv);
+const ts::string_view IP_PROTO_TAG_HTTP_2_0("h2"_sv); // HTTP/2 over TLS
 
 uint32_t
 ink_inet_addr(const char *s)
@@ -138,11 +139,10 @@ ats_ip_ntop(const struct sockaddr *addr, char *dst, size_t size)
   return zret;
 }
 
-ts::StringView
+ts::string_view
 ats_ip_family_name(int family)
 {
-  static const ts::StringView UNSPEC("Unspec", ts::StringView::literal);
-  return AF_INET == family ? IP_PROTO_TAG_IPV4 : AF_INET6 == family ? IP_PROTO_TAG_IPV6 : UNSPEC;
+  return AF_INET == family ? IP_PROTO_TAG_IPV4 : AF_INET6 == family ? IP_PROTO_TAG_IPV6 : "Unspec"_sv;
 }
 
 const char *
@@ -154,28 +154,27 @@ ats_ip_nptop(sockaddr const *addr, char *dst, size_t size)
 }
 
 int
-ats_ip_parse(ts::ConstBuffer src, ts::ConstBuffer *addr, ts::ConstBuffer *port, ts::ConstBuffer *rest)
+ats_ip_parse(ts::string_view str, ts::string_view *addr, ts::string_view *port, ts::string_view *rest)
 {
   // In case the incoming arguments are null.
-  ts::ConstBuffer localAddr, localPort;
+  ts::string_view localAddr, localPort;
+  ts::StringView src(str);
   if (!addr) {
     addr = &localAddr;
   }
   if (!port) {
     port = &localPort;
   }
-  addr->reset();
-  port->reset();
+  ink_zero(*addr);
+  ink_zero(*port);
   if (rest) {
-    rest->reset();
+    ink_zero(*rest);
   }
 
   // Let's see if we can find out what's in the address string.
   if (src) {
     bool colon_p = false;
-    while (src && ParseRules::is_ws(*src)) {
-      ++src;
-    }
+    src.ltrim(&ParseRules::is_ws);
     // Check for brackets.
     if ('[' == *src) {
       /* Ugly. In a number of places we must use bracket notation
@@ -193,45 +192,43 @@ ats_ip_parse(ts::ConstBuffer src, ts::ConstBuffer *addr, ts::ConstBuffer *port,
          So we can't depend on that sizing.
       */
       ++src; // skip bracket.
-      *addr = src.splitOn(']');
+      *addr = src.extractPrefix(']');
       if (':' == *src) {
         colon_p = true;
         ++src;
       }
     } else {
-      ts::ConstBuffer post = src.after(':');
-      if (post.data() && !post.find(':')) {
-        *addr   = src.splitOn(post.data() - 1);
+      ts::StringView post = src.suffix(':');
+      if (post.ptr() && !post.find(':')) {
+        *addr   = src.extractPrefix(post.ptr() - 1);
         colon_p = true;
       } else { // presume no port, use everything.
         *addr = src;
-        src.reset();
+        src.clear();
       }
     }
     if (colon_p) {
-      ts::ConstBuffer tmp(src);
-      while (src && ParseRules::is_digit(*src)) {
-        ++src;
-      }
+      ts::StringView tmp(src);
+      src.ltrim(&ParseRules::is_digit);
 
-      if (tmp.data() == src.data()) {            // no digits at all
-        src.set(tmp.data() - 1, tmp.size() + 1); // back up to include colon
+      if (tmp.ptr() == src.ptr()) {                 // no digits at all
+        src.setView(tmp.ptr() - 1, tmp.size() + 1); // back up to include colon
       } else {
-        *port = tmp.clip(src.data());
+        *port = ts::string_view(tmp.ptr(), src.ptr() - tmp.ptr());
       }
     }
     if (rest) {
       *rest = src;
     }
   }
-  return *addr ? 0 : -1; // true if we found an address.
+  return addr->empty() ? -1 : 0; // true if we found an address.
 }
 
 int
-ats_ip_pton(const ts::ConstBuffer &src, sockaddr *ip)
+ats_ip_pton(const ts::string_view &src, sockaddr *ip)
 {
   int zret = -1;
-  ts::ConstBuffer addr, port;
+  ts::string_view addr, port;
 
   ats_ip_invalidate(ip);
   if (0 == ats_ip_parse(src, &addr, &port)) {
@@ -240,9 +237,9 @@ ats_ip_pton(const ts::ConstBuffer &src, sockaddr *ip)
       char *tmp = static_cast<char *>(alloca(addr.size() + 1));
       memcpy(tmp, addr.data(), addr.size());
       tmp[addr.size()] = 0;
-      addr.set(tmp, addr.size());
+      addr             = ts::string_view(tmp, addr.size());
     }
-    if (addr.find(':')) { // colon -> IPv6
+    if (addr.find(':') != ts::string_view::npos) { // colon -> IPv6
       in6_addr addr6;
       if (inet_pton(AF_INET6, addr.data(), &addr6)) {
         zret = 0;
@@ -257,7 +254,7 @@ ats_ip_pton(const ts::ConstBuffer &src, sockaddr *ip)
     }
     // If we had a successful conversion, set the port.
     if (ats_is_ip(ip)) {
-      ats_ip_port_cast(ip) = port ? htons(atoi(port.data())) : 0;
+      ats_ip_port_cast(ip) = port.empty() ? 0 : htons(atoi(port.data()));
     }
   }
 
@@ -344,7 +341,7 @@ IpAddr::load(const char *text)
 }
 
 int
-IpAddr::load(ts::ConstBuffer const &text)
+IpAddr::load(ts::string_view const &text)
 {
   IpEndpoint ip;
   int zret = ats_ip_pton(text, &ip.sa);
@@ -446,8 +443,8 @@ ats_ip_getbestaddrinfo(const char *host, IpEndpoint *ip4, IpEndpoint *ip6)
   int port = 0; // port value to assign if we find an address.
   addrinfo ai_hints;
   addrinfo *ai_result;
-  ts::ConstBuffer addr_text, port_text;
-  ts::ConstBuffer src(host, strlen(host) + 1);
+  ts::string_view addr_text, port_text;
+  ts::string_view src(host, strlen(host) + 1);
 
   if (ip4) {
     ats_ip_invalidate(ip4);
@@ -462,7 +459,7 @@ ats_ip_getbestaddrinfo(const char *host, IpEndpoint *ip4, IpEndpoint *ip6)
       char *tmp = static_cast<char *>(alloca(addr_text.size() + 1));
       memcpy(tmp, addr_text.data(), addr_text.size());
       tmp[addr_text.size()] = 0;
-      addr_text.set(tmp, addr_text.size());
+      addr_text             = ts::string_view(tmp, addr_text.size());
     }
     ink_zero(ai_hints);
     ai_hints.ai_family = AF_UNSPEC;
@@ -546,7 +543,7 @@ ats_ip_getbestaddrinfo(const char *host, IpEndpoint *ip4, IpEndpoint *ip6)
 }
 
 int
-ats_ip_check_characters(ts::ConstBuffer text)
+ats_ip_check_characters(ts::string_view text)
 {
   bool found_colon = false;
   bool found_hex   = false;
@@ -600,10 +597,10 @@ REGRESSION_TEST(Ink_Inet)(RegressionTest *t, int /* atype */, int *pstatus)
 
     for (unsigned i = 0; i < countof(names); ++i) {
       ip_parse_spec const &s = names[i];
-      ts::ConstBuffer host, port, rest;
+      ts::string_view host, port, rest;
       size_t len;
 
-      box.check(ats_ip_parse(ts::ConstBuffer(s.hostspec, strlen(s.hostspec)), &host, &port, &rest) == 0, "ats_ip_parse(%s)",
+      box.check(ats_ip_parse(ts::string_view(s.hostspec, strlen(s.hostspec)), &host, &port, &rest) == 0, "ats_ip_parse(%s)",
                 s.hostspec);
       len = strlen(s.host);
       box.check(len == host.size() && strncmp(host.data(), s.host, host.size()) == 0, "ats_ip_parse(%s) gave addr '%.*s'",
diff --git a/lib/ts/ink_inet.h b/lib/ts/ink_inet.h
index 2f0c757..4f52bec 100644
--- a/lib/ts/ink_inet.h
+++ b/lib/ts/ink_inet.h
@@ -30,8 +30,7 @@
 #include <sys/socket.h>
 #include "ts/ink_memory.h"
 #include "ts/ink_apidefs.h"
-#include "ts/TsBuffer.h"
-#include <ts/MemView.h>
+#include <ts/string_view.h>
 
 #if !TS_HAS_IN6_IS_ADDR_UNSPECIFIED
 #if defined(IN6_IS_ADDR_UNSPECIFIED)
@@ -46,18 +45,18 @@ IN6_IS_ADDR_UNSPECIFIED(in6_addr const *addr)
 #endif
 
 // IP protocol stack tags.
-extern const ts::StringView IP_PROTO_TAG_IPV4;
-extern const ts::StringView IP_PROTO_TAG_IPV6;
-extern const ts::StringView IP_PROTO_TAG_UDP;
-extern const ts::StringView IP_PROTO_TAG_TCP;
-extern const ts::StringView IP_PROTO_TAG_TLS_1_0;
-extern const ts::StringView IP_PROTO_TAG_TLS_1_1;
-extern const ts::StringView IP_PROTO_TAG_TLS_1_2;
-extern const ts::StringView IP_PROTO_TAG_TLS_1_3;
-extern const ts::StringView IP_PROTO_TAG_HTTP_0_9;
-extern const ts::StringView IP_PROTO_TAG_HTTP_1_0;
-extern const ts::StringView IP_PROTO_TAG_HTTP_1_1;
-extern const ts::StringView IP_PROTO_TAG_HTTP_2_0;
+extern const ts::string_view IP_PROTO_TAG_IPV4;
+extern const ts::string_view IP_PROTO_TAG_IPV6;
+extern const ts::string_view IP_PROTO_TAG_UDP;
+extern const ts::string_view IP_PROTO_TAG_TCP;
+extern const ts::string_view IP_PROTO_TAG_TLS_1_0;
+extern const ts::string_view IP_PROTO_TAG_TLS_1_1;
+extern const ts::string_view IP_PROTO_TAG_TLS_1_2;
+extern const ts::string_view IP_PROTO_TAG_TLS_1_3;
+extern const ts::string_view IP_PROTO_TAG_HTTP_0_9;
+extern const ts::string_view IP_PROTO_TAG_HTTP_1_0;
+extern const ts::string_view IP_PROTO_TAG_HTTP_1_1;
+extern const ts::string_view IP_PROTO_TAG_HTTP_2_0;
 
 struct IpAddr; // forward declare.
 
@@ -140,10 +139,10 @@ int ats_tcp_somaxconn();
 
     @return 0 if an address was found, non-zero otherwise.
 */
-int ats_ip_parse(ts::ConstBuffer src,      ///< [in] String to search.
-                 ts::ConstBuffer *addr,    ///< [out] Range containing IP address.
-                 ts::ConstBuffer *port,    ///< [out] Range containing port.
-                 ts::ConstBuffer *rest = 0 ///< [out] Remnant past the addr/port if any.
+int ats_ip_parse(ts::string_view src,      ///< [in] String to search.
+                 ts::string_view *addr,    ///< [out] Range containing IP address.
+                 ts::string_view *port,    ///< [out] Range containing port.
+                 ts::string_view *rest = 0 ///< [out] Remnant past the addr/port if any.
                  );
 
 /**  Check to see if a buffer contains only IP address characters.
@@ -152,7 +151,7 @@ int ats_ip_parse(ts::ConstBuffer src,      ///< [in] String to search.
     - AF_INET - only digits and dots.
     - AF_INET6 - colons found.
 */
-int ats_ip_check_characters(ts::ConstBuffer text);
+int ats_ip_check_characters(ts::string_view text);
 
 /**
   Wrapper for inet_addr().
@@ -189,7 +188,7 @@ ats_ip_invalidate(IpEndpoint *ip)
 /** Get a string name for an IP address family.
     @return The string name (never @c nullptr).
 */
-ts::StringView ats_ip_family_name(int family);
+ts::string_view ats_ip_family_name(int family);
 
 /// Test for IP protocol.
 /// @return @c true if the address is IP, @c false otherwise.
@@ -1045,7 +1044,7 @@ ats_ip_nptop(IpEndpoint const *addr, ///< Address.
 
     @return 0 on success, non-zero on failure.
 */
-int ats_ip_pton(const ts::ConstBuffer &text, ///< [in] text.
+int ats_ip_pton(const ts::string_view &text, ///< [in] text.
                 sockaddr *addr               ///< [out] address
                 );
 
@@ -1065,11 +1064,11 @@ ats_ip_pton(const char *text,  ///< [in] text.
             sockaddr_in6 *addr ///< [out] address
             )
 {
-  return ats_ip_pton(ts::ConstBuffer(text, strlen(text)), ats_ip_sa_cast(addr));
+  return ats_ip_pton(ts::string_view(text, strlen(text)), ats_ip_sa_cast(addr));
 }
 
 inline int
-ats_ip_pton(const ts::ConstBuffer &text, ///< [in] text.
+ats_ip_pton(const ts::string_view &text, ///< [in] text.
             IpEndpoint *addr             ///< [out] address
             )
 {
@@ -1081,7 +1080,7 @@ ats_ip_pton(const char *text, ///< [in] text.
             IpEndpoint *addr  ///< [out] address
             )
 {
-  return ats_ip_pton(ts::ConstBuffer(text, strlen(text)), &addr->sa);
+  return ats_ip_pton(ts::string_view(text, strlen(text)), &addr->sa);
 }
 
 inline int
@@ -1089,7 +1088,7 @@ ats_ip_pton(const char *text, ///< [in] text.
             sockaddr *addr    ///< [out] address
             )
 {
-  return ats_ip_pton(ts::ConstBuffer(text, strlen(text)), addr);
+  return ats_ip_pton(ts::string_view(text, strlen(text)), addr);
 }
 
 /** Get the best address info for @a name.
@@ -1201,7 +1200,7 @@ struct IpAddr {
       otherwise this object is invalidated.
       @return 0 on success, non-zero on failure.
   */
-  int load(ts::ConstBuffer const &str ///< Text of IP address.
+  int load(ts::string_view const &str ///< Text of IP address.
            );
 
   /** Output to a string.
diff --git a/lib/ts/ink_res_init.cc b/lib/ts/ink_res_init.cc
index 8bcf4d3..f991698 100644
--- a/lib/ts/ink_res_init.cc
+++ b/lib/ts/ink_res_init.cc
@@ -515,7 +515,7 @@ ink_res_init(ink_res_state statp,         ///< State object to update.
           cp++;
         }
         if ((*cp != '\0') && (*cp != '\n')) {
-          ts::ConstBuffer host(cp, strcspn(cp, ";# \t\n"));
+          ts::string_view host(cp, strcspn(cp, ";# \t\n"));
           if (0 == ats_ip_pton(host, &statp->nsaddr_list[nserv].sa)) {
             // If there was no port in the config, lets use NAMESERVER_PORT
             if (ats_ip_port_host_order(&statp->nsaddr_list[nserv].sa) == 0) {
diff --git a/lib/ts/string_view.h b/lib/ts/string_view.h
index 9535e22..b68e56d 100644
--- a/lib/ts/string_view.h
+++ b/lib/ts/string_view.h
@@ -33,6 +33,7 @@
 #include <utility>
 #include <string>
 #include <ostream>
+#include <cstring>
 
 #if __cplusplus < 201402
 #define CONSTEXPR14 inline
@@ -1219,3 +1220,20 @@ constexpr ts::string_view operator"" _sv(const char *str, size_t len) noexcept
 {
   return ts::string_view(str, len);
 }
+
+// TS local extensions, not dependent on our local implementation of std::string_view.
+
+/// Check for prefix.
+/// @return @c true if @a lhs is a prefix (ignoring case) of @a rhs.
+inline bool
+IsNoCasePrefixOf(ts::string_view const &lhs, ts::string_view const &rhs)
+{
+  return lhs.size() <= rhs.size() && 0 == strncasecmp(lhs.data(), rhs.data(), lhs.size());
+}
+/// Check for prefix.
+/// @return @c true if @a lhs is a prefix of @a rhs.
+inline bool
+IsPrefixOf(ts::string_view const &lhs, ts::string_view const &rhs)
+{
+  return lhs.size() <= rhs.size() && 0 == memcmp(lhs.data(), rhs.data(), lhs.size());
+}
diff --git a/lib/ts/unit-tests/test_layout.cc b/lib/ts/unit-tests/test_layout.cc
index 59facae..fa368f2 100644
--- a/lib/ts/unit-tests/test_layout.cc
+++ b/lib/ts/unit-tests/test_layout.cc
@@ -1,6 +1,9 @@
 /** @file
+
   Test file for layout structure
+
   @section license License
+
   Licensed to the Apache Software Foundation (ASF) under one
   or more contributor license agreements.  See the NOTICE file
   distributed with this work for additional information
diff --git a/mgmt/LocalManager.cc b/mgmt/LocalManager.cc
index 73285ab..4b778ab 100644
--- a/mgmt/LocalManager.cc
+++ b/mgmt/LocalManager.cc
@@ -31,6 +31,7 @@
 #include "MgmtSocket.h"
 #include "ts/ink_cap.h"
 #include "FileManager.h"
+#include <ts/MemView.h>
 
 #if TS_USE_POSIX_CAP
 #include <sys/capability.h>
diff --git a/plugins/experimental/ssl_cert_loader/ssl-cert-loader.cc b/plugins/experimental/ssl_cert_loader/ssl-cert-loader.cc
index 8ed0906..34fd419 100644
--- a/plugins/experimental/ssl_cert_loader/ssl-cert-loader.cc
+++ b/plugins/experimental/ssl_cert_loader/ssl-cert-loader.cc
@@ -83,18 +83,17 @@ using IpRangeQueue = std::deque<IpRange>;
 Configuration Config; // global configuration
 
 void
-Parse_Addr_String(ts::ConstBuffer const &text, IpRange &range)
+Parse_Addr_String(ts::string_view const &text, IpRange &range)
 {
   IpAddr newAddr;
-  std::string textstr(text._ptr, text._size);
   // Is there a hyphen?
-  size_t hyphen_pos = textstr.find('-');
+  size_t hyphen_pos = text.find('-');
 
-  if (hyphen_pos != std::string::npos) {
-    std::string addr1 = textstr.substr(0, hyphen_pos);
-    std::string addr2 = textstr.substr(hyphen_pos + 1);
-    range.first.load(ts::ConstBuffer(addr1.c_str(), addr1.length()));
-    range.second.load(ts::ConstBuffer(addr2.c_str(), addr2.length()));
+  if (hyphen_pos != ts::string_view::npos) {
+    ts::string_view addr1 = text.substr(0, hyphen_pos);
+    ts::string_view addr2 = text.substr(hyphen_pos + 1);
+    range.first.load(addr1);
+    range.second.load(addr2);
   } else { // Assume it is a single address
     newAddr.load(text);
     range.first  = newAddr;
@@ -269,8 +268,9 @@ Parse_Config(Value &parent, ParsedSslValues &orig_values)
   val = parent.find("server-ip");
   if (val) {
     IpRange ipRange;
+    auto txt = val.getText();
 
-    Parse_Addr_String(val.getText(), ipRange);
+    Parse_Addr_String(ts::string_view(txt._ptr, txt._size), ipRange);
     cur_values.server_ips.push_back(ipRange);
   }
   val = parent.find("server-name");
diff --git a/proxy/InkAPI.cc b/proxy/InkAPI.cc
index aef9526..a338c72 100644
--- a/proxy/InkAPI.cc
+++ b/proxy/InkAPI.cc
@@ -60,7 +60,7 @@
 #include "I_RecCore.h"
 #include "I_Machine.h"
 #include "HttpProxyServerMain.h"
-#include <ts/MemView.h>
+#include <ts/string_view.h>
 
 #include "api/ts/ts.h"
 
@@ -9366,10 +9366,10 @@ TSHttpTxnClientProtocolStackGet(TSHttpTxn txnp, int n, const char **result, int
   HttpSM *sm = reinterpret_cast<HttpSM *>(txnp);
   int count  = 0;
   if (sm && n > 0) {
-    auto mem = static_cast<ts::StringView *>(alloca(sizeof(ts::StringView) * n));
+    auto mem = static_cast<ts::string_view *>(alloca(sizeof(ts::string_view) * n));
     count    = sm->populate_client_protocol(mem, n);
     for (int i = 0; i < count; ++i) {
-      result[i] = mem[i].ptr();
+      result[i] = mem[i].data();
     }
   }
   if (actual) {
@@ -9386,10 +9386,10 @@ TSHttpSsnClientProtocolStackGet(TSHttpSsn ssnp, int n, const char **result, int
   ProxyClientSession *cs = reinterpret_cast<ProxyClientSession *>(ssnp);
   int count              = 0;
   if (cs && n > 0) {
-    auto mem = static_cast<ts::StringView *>(alloca(sizeof(ts::StringView) * n));
+    auto mem = static_cast<ts::string_view *>(alloca(sizeof(ts::string_view) * n));
     count    = cs->populate_protocol(mem, n);
     for (int i = 0; i < count; ++i) {
-      result[i] = mem[i].ptr();
+      result[i] = mem[i].data();
     }
   }
   if (actual) {
@@ -9409,7 +9409,7 @@ TSHttpTxnClientProtocolStackContains(TSHttpTxn txnp, const char *tag)
 {
   sdk_assert(sdk_sanity_check_txn(txnp) == TS_SUCCESS);
   HttpSM *sm = (HttpSM *)txnp;
-  return sm->client_protocol_contains(ts::StringView(tag));
+  return sm->client_protocol_contains(ts::string_view{tag});
 }
 
 const char *
@@ -9417,7 +9417,7 @@ TSHttpSsnClientProtocolStackContains(TSHttpSsn ssnp, const char *tag)
 {
   sdk_assert(sdk_sanity_check_http_ssn(ssnp) == TS_SUCCESS);
   ProxyClientSession *cs = reinterpret_cast<ProxyClientSession *>(ssnp);
-  return cs->protocol_contains(ts::StringView(tag));
+  return cs->protocol_contains(ts::string_view{tag});
 }
 
 const char *
diff --git a/proxy/ProxyClientSession.h b/proxy/ProxyClientSession.h
index f25b915..9a64fb8 100644
--- a/proxy/ProxyClientSession.h
+++ b/proxy/ProxyClientSession.h
@@ -189,14 +189,14 @@ public:
   }
 
   virtual int
-  populate_protocol(ts::StringView *result, int size) const
+  populate_protocol(ts::string_view *result, int size) const
   {
     auto vc = this->get_netvc();
     return vc ? vc->populate_protocol(result, size) : 0;
   }
 
   virtual const char *
-  protocol_contains(ts::StringView tag_prefix) const
+  protocol_contains(ts::string_view tag_prefix) const
   {
     auto vc = this->get_netvc();
     return vc ? vc->protocol_contains(tag_prefix) : nullptr;
diff --git a/proxy/ProxyClientTransaction.h b/proxy/ProxyClientTransaction.h
index daf8b71..a7ea8a5 100644
--- a/proxy/ProxyClientTransaction.h
+++ b/proxy/ProxyClientTransaction.h
@@ -240,13 +240,13 @@ public:
   }
 
   virtual int
-  populate_protocol(ts::StringView *result, int size) const
+  populate_protocol(ts::string_view *result, int size) const
   {
     return parent ? parent->populate_protocol(result, size) : 0;
   }
 
   virtual const char *
-  protocol_contains(ts::StringView tag_prefix) const
+  protocol_contains(ts::string_view tag_prefix) const
   {
     return parent ? parent->protocol_contains(tag_prefix) : nullptr;
   }
diff --git a/proxy/hdrs/HTTP.cc b/proxy/hdrs/HTTP.cc
index d6be78d..69335e0 100644
--- a/proxy/hdrs/HTTP.cc
+++ b/proxy/hdrs/HTTP.cc
@@ -1130,9 +1130,9 @@ validate_hdr_host(HTTPHdrImpl *hh)
     } else {
       int host_len         = 0;
       const char *host_val = host_field->value_get(&host_len);
-      ts::ConstBuffer addr, port, rest, host(host_val, host_len);
+      ts::string_view addr, port, rest, host(host_val, host_len);
       if (0 == ats_ip_parse(host, &addr, &port, &rest)) {
-        if (port) {
+        if (!port.empty()) {
           if (port.size() > 5) {
             return PARSE_RESULT_ERROR;
           }
@@ -1144,11 +1144,8 @@ validate_hdr_host(HTTPHdrImpl *hh)
         if (!validate_host_name(addr)) {
           return PARSE_RESULT_ERROR;
         }
-        while (rest && PARSE_RESULT_DONE == ret) {
-          if (!ParseRules::is_ws(*rest)) {
-            return PARSE_RESULT_ERROR;
-          }
-          ++rest;
+        if (PARSE_RESULT_DONE == ret && !std::all_of(rest.begin(), rest.end(), &ParseRules::is_ws)) {
+          return PARSE_RESULT_ERROR;
         }
       } else {
         ret = PARSE_RESULT_ERROR;
diff --git a/proxy/hdrs/URL.cc b/proxy/hdrs/URL.cc
index 372c2f3..2846f54 100644
--- a/proxy/hdrs/URL.cc
+++ b/proxy/hdrs/URL.cc
@@ -109,15 +109,9 @@ is_host_char(char c)
 
 // Checks if `addr` is a valid FQDN string
 bool
-validate_host_name(ts::ConstBuffer addr)
+validate_host_name(ts::string_view addr)
 {
-  while (addr) {
-    if (!(is_host_char(*addr))) {
-      return false;
-    }
-    ++addr;
-  }
-  return true;
+  return std::all_of(addr.begin(), addr.end(), &is_host_char);
 }
 
 /*-------------------------------------------------------------------------
@@ -1337,7 +1331,7 @@ url_parse_internet(HdrHeap *heap, URLImpl *url, const char **start, char const *
     }
   }
   if (host._size) {
-    if (validate_host_name(host)) {
+    if (validate_host_name(ts::string_view(host._ptr, host._size))) {
       url_host_set(heap, url, host._ptr, host._size, copy_strings_p);
     } else {
       return PARSE_RESULT_ERROR;
@@ -1856,8 +1850,7 @@ REGRESSION_TEST(VALIDATE_HDR_FIELD)(RegressionTest *t, int /* level ATS_UNUSED *
 
   for (auto i : http_validate_hdr_field_test_case) {
     const char *const txt = i.text;
-    ts::ConstBuffer tmp   = ts::ConstBuffer(txt, strlen(txt));
-    box.check(validate_host_name(tmp) == i.valid, "Validation of FQDN (host) header: \"%s\", expected %s, but not", txt,
+    box.check(validate_host_name({txt}) == i.valid, "Validation of FQDN (host) header: \"%s\", expected %s, but not", txt,
               (i.valid ? "true" : "false"));
   }
 }
diff --git a/proxy/hdrs/URL.h b/proxy/hdrs/URL.h
index a7521d0..d34a936 100644
--- a/proxy/hdrs/URL.h
+++ b/proxy/hdrs/URL.h
@@ -30,7 +30,7 @@
 #include "ts/INK_MD5.h"
 #include "ts/MMH.h"
 #include "MIME.h"
-#include "ts/TsBuffer.h"
+#include <ts/string_view.h>
 
 #include "ts/ink_apidefs.h"
 
@@ -194,7 +194,7 @@ extern int URL_LEN_MMST;
 void url_adjust(MarshalXlate *str_xlate, int num_xlate);
 
 /* Public */
-bool validate_host_name(ts::ConstBuffer addr);
+bool validate_host_name(ts::string_view addr);
 void url_init();
 
 URLImpl *url_create(HdrHeap *heap);
diff --git a/proxy/http/HttpSM.cc b/proxy/http/HttpSM.cc
index 1d98f31..addd1ed 100644
--- a/proxy/http/HttpSM.cc
+++ b/proxy/http/HttpSM.cc
@@ -49,8 +49,6 @@
 #include "congest/Congestion.h"
 #include "ts/I_Layout.h"
 
-using ts::StringView;
-
 #define DEFAULT_RESPONSE_BUFFER_SIZE_INDEX 6 // 8K
 #define DEFAULT_REQUEST_BUFFER_SIZE_INDEX 6  // 8K
 #define MIN_CONFIG_BUFFER_SIZE_INDEX 5       // 4K
@@ -4629,7 +4627,8 @@ void
 HttpSM::do_http_server_open(bool raw)
 {
   int ip_family = t_state.current.server->dst_addr.sa.sa_family;
-  DebugSM("http_track", "entered inside do_http_server_open ][%s]", ats_ip_family_name(ip_family).ptr());
+  auto fam_name = ats_ip_family_name(ip_family);
+  DebugSM("http_track", "entered inside do_http_server_open ][%.*s]", static_cast<int>(fam_name.size()), fam_name.data());
 
   // Make sure we are on the "right" thread
   if (ua_session) {
@@ -7975,12 +7974,12 @@ HttpSM::is_redirect_required()
 
 // Fill in the client protocols used.  Return the number of entries returned
 int
-HttpSM::populate_client_protocol(ts::StringView *result, int n) const
+HttpSM::populate_client_protocol(ts::string_view *result, int n) const
 {
   int retval = 0;
   if (n > 0) {
-    StringView proto = HttpSM::find_proto_string(t_state.hdr_info.client_request.version_get());
-    if (proto) {
+    ts::string_view proto = HttpSM::find_proto_string(t_state.hdr_info.client_request.version_get());
+    if (!proto.empty()) {
       result[retval++] = proto;
       if (n > retval && ua_session) {
         retval += ua_session->populate_protocol(result + retval, n - retval);
@@ -7992,14 +7991,14 @@ HttpSM::populate_client_protocol(ts::StringView *result, int n) const
 
 // Look for a specific protocol
 const char *
-HttpSM::client_protocol_contains(StringView tag_prefix) const
-{
-  const char *retval = nullptr;
-  StringView proto   = HttpSM::find_proto_string(t_state.hdr_info.client_request.version_get());
-  if (proto) {
-    StringView prefix(tag_prefix);
-    if (prefix.size() <= proto.size() && 0 == strncmp(proto.ptr(), prefix.ptr(), prefix.size())) {
-      retval = proto.ptr();
+HttpSM::client_protocol_contains(ts::string_view tag_prefix) const
+{
+  const char *retval    = nullptr;
+  ts::string_view proto = HttpSM::find_proto_string(t_state.hdr_info.client_request.version_get());
+  if (!proto.empty()) {
+    ts::string_view prefix(tag_prefix);
+    if (prefix.size() <= proto.size() && 0 == strncmp(proto.data(), prefix.data(), prefix.size())) {
+      retval = proto.data();
     } else if (ua_session) {
       retval = ua_session->protocol_contains(prefix);
     }
@@ -8007,7 +8006,7 @@ HttpSM::client_protocol_contains(StringView tag_prefix) const
   return retval;
 }
 
-StringView
+ts::string_view
 HttpSM::find_proto_string(HTTPVersion version) const
 {
   if (version == HTTPVersion(1, 1)) {
diff --git a/proxy/http/HttpSM.h b/proxy/http/HttpSM.h
index 46400d6..0b68390 100644
--- a/proxy/http/HttpSM.h
+++ b/proxy/http/HttpSM.h
@@ -274,9 +274,9 @@ public:
   /// Get the protocol stack for the inbound (client, user agent) connection.
   /// @arg result [out] Array to store the results
   /// @arg n [in] Size of the array @a result.
-  int populate_client_protocol(ts::StringView *result, int n) const;
-  const char *client_protocol_contains(ts::StringView tag_prefix) const;
-  ts::StringView find_proto_string(HTTPVersion version) const;
+  int populate_client_protocol(ts::string_view *result, int n) const;
+  const char *client_protocol_contains(ts::string_view tag_prefix) const;
+  ts::string_view find_proto_string(HTTPVersion version) const;
 
   int64_t sm_id      = -1;
   unsigned int magic = HTTP_SM_MAGIC_DEAD;
diff --git a/proxy/http/HttpServerSession.h b/proxy/http/HttpServerSession.h
index dcc841c..48624d6 100644
--- a/proxy/http/HttpServerSession.h
+++ b/proxy/http/HttpServerSession.h
@@ -181,14 +181,14 @@ public:
   MIOBuffer *read_buffer;
 
   virtual int
-  populate_protocol(ts::StringView *result, int size) const
+  populate_protocol(ts::string_view *result, int size) const
   {
     auto vc = this->get_netvc();
     return vc ? vc->populate_protocol(result, size) : 0;
   }
 
   virtual const char *
-  protocol_contains(ts::StringView tag_prefix) const
+  protocol_contains(ts::string_view tag_prefix) const
   {
     auto vc = this->get_netvc();
     return vc ? vc->protocol_contains(tag_prefix) : nullptr;
diff --git a/proxy/http/HttpTransactHeaders.cc b/proxy/http/HttpTransactHeaders.cc
index 358dd45..fa704a4 100644
--- a/proxy/http/HttpTransactHeaders.cc
+++ b/proxy/http/HttpTransactHeaders.cc
@@ -693,30 +693,29 @@ HttpTransactHeaders::insert_server_header_in_response(const char *server_tag, in
 /// If @a detailed then do the full stack, otherwise just the "top level" protocol.
 /// Returns the number of characters appended to hdr_string (no nul appended).
 int
-HttpTransactHeaders::write_hdr_protocol_stack(char *hdr_string, size_t len, ProtocolStackDetail pSDetail, ts::StringView *proto_buf,
-                                              int n_proto, char separator)
+HttpTransactHeaders::write_hdr_protocol_stack(char *hdr_string, size_t len, ProtocolStackDetail pSDetail,
+                                              ts::string_view *proto_buf, int n_proto, char separator)
 {
   char *hdr   = hdr_string; // keep original pointer for size computation later.
   char *limit = hdr_string + len;
-  static constexpr ts::StringView tls_prefix{"tls/", ts::StringView::literal};
 
   if (n_proto <= 0 || hdr == nullptr || len <= 0) {
     // nothing
   } else if (ProtocolStackDetail::Full == pSDetail) {
-    for (ts::StringView *v = proto_buf, *v_limit = proto_buf + n_proto; v < v_limit && (hdr + v->size() + 1) < limit; ++v) {
+    for (ts::string_view *v = proto_buf, *v_limit = proto_buf + n_proto; v < v_limit && (hdr + v->size() + 1) < limit; ++v) {
       if (v != proto_buf) {
         *hdr++ = separator;
       }
-      memcpy(hdr, v->ptr(), v->size());
+      memcpy(hdr, v->data(), v->size());
       hdr += v->size();
     }
   } else {
-    ts::StringView *proto_end = proto_buf + n_proto;
-    bool http_1_0_p           = std::find(proto_buf, proto_end, IP_PROTO_TAG_HTTP_1_0) != proto_end;
-    bool http_1_1_p           = std::find(proto_buf, proto_end, IP_PROTO_TAG_HTTP_1_1) != proto_end;
+    ts::string_view *proto_end = proto_buf + n_proto;
+    bool http_1_0_p            = std::find(proto_buf, proto_end, IP_PROTO_TAG_HTTP_1_0) != proto_end;
+    bool http_1_1_p            = std::find(proto_buf, proto_end, IP_PROTO_TAG_HTTP_1_1) != proto_end;
 
     if ((http_1_0_p || http_1_1_p) && hdr + 10 < limit) {
-      bool tls_p = std::find_if(proto_buf, proto_end, [](ts::StringView tag) { return tls_prefix.isPrefixOf(tag); }) != proto_end;
+      bool tls_p = std::find_if(proto_buf, proto_end, [](ts::string_view tag) { return IsPrefixOf("tls/"_sv, tag); }) != proto_end;
 
       memcpy(hdr, "http", 4);
       hdr += 4;
@@ -800,7 +799,7 @@ HttpTransactHeaders::insert_via_header_in_request(HttpTransact::State *s, HTTPHd
   }
 
   char *incoming_via = s->via_string;
-  std::array<ts::StringView, 10> proto_buf; // 10 seems like a reasonable number of protos to print
+  std::array<ts::string_view, 10> proto_buf; // 10 seems like a reasonable number of protos to print
   int n_proto = s->state_machine->populate_client_protocol(proto_buf.data(), proto_buf.size());
 
   via_string +=
@@ -882,7 +881,7 @@ HttpTransactHeaders::insert_via_header_in_response(HttpTransact::State *s, HTTPH
   }
 
   char *incoming_via = s->via_string;
-  std::array<ts::StringView, 10> proto_buf; // 10 seems like a reasonable number of protos to print
+  std::array<ts::string_view, 10> proto_buf; // 10 seems like a reasonable number of protos to print
   int n_proto = 0;
 
   // Should suffice - if we're adding a response VIA, the connection is HTTP and only 1.0 and 1.1 are supported outbound.
@@ -1102,8 +1101,8 @@ HttpTransactHeaders::add_forwarded_field_to_request(HttpTransact::State *s, HTTP
       }
     }
 
-    std::array<ts::StringView, 10> protoBuf; // 10 seems like a reasonable number of protos to print
-    int nProto = 0;                          // Indulge clang's incorrect claim that this need to be initialized.
+    std::array<ts::string_view, 10> protoBuf; // 10 seems like a reasonable number of protos to print
+    int n_proto = 0;                          // Indulge clang's incorrect claim that this need to be initialized.
 
     static const HttpForwarded::OptionBitSet OptionsNeedingProtocol = HttpForwarded::OptionBitSet()
                                                                         .set(HttpForwarded::PROTO)
@@ -1112,18 +1111,18 @@ HttpTransactHeaders::add_forwarded_field_to_request(HttpTransact::State *s, HTTP
                                                                         .set(HttpForwarded::CONNECTION_FULL);
 
     if ((optSet bitand OptionsNeedingProtocol).any()) {
-      nProto = s->state_machine->populate_client_protocol(protoBuf.data(), protoBuf.size());
+      n_proto = s->state_machine->populate_client_protocol(protoBuf.data(), protoBuf.size());
     }
 
-    if (optSet[HttpForwarded::PROTO] and (nProto > 0)) {
+    if (optSet[HttpForwarded::PROTO] and (n_proto > 0)) {
       if (hdr.size()) {
         hdr << ';';
       }
 
       hdr << "proto=";
 
-      int numChars = HttpTransactHeaders::write_hdr_protocol_stack(
-        hdr.auxBuffer(), hdr.remaining(), HttpTransactHeaders::ProtocolStackDetail::Compact, protoBuf.data(), nProto, '-');
+      int numChars = HttpTransactHeaders::write_hdr_protocol_stack(hdr.auxBuffer(), hdr.remaining(), ProtocolStackDetail::Compact,
+                                                                   protoBuf.data(), n_proto, '-');
       if (numChars > 0) {
         hdr.write(size_t(numChars));
       }
@@ -1152,7 +1151,7 @@ HttpTransactHeaders::add_forwarded_field_to_request(HttpTransact::State *s, HTTP
       }
     }
 
-    if (nProto > 0) {
+    if (n_proto > 0) {
       auto Conn = [&](HttpForwarded::Option opt, HttpTransactHeaders::ProtocolStackDetail detail) -> void {
         if (optSet[opt]) {
           int revert = hdr.size();
@@ -1164,7 +1163,7 @@ HttpTransactHeaders::add_forwarded_field_to_request(HttpTransact::State *s, HTTP
           hdr << "connection=";
 
           int numChars =
-            HttpTransactHeaders::write_hdr_protocol_stack(hdr.auxBuffer(), hdr.remaining(), detail, protoBuf.data(), nProto, '-');
+            HttpTransactHeaders::write_hdr_protocol_stack(hdr.auxBuffer(), hdr.remaining(), detail, protoBuf.data(), n_proto, '-');
           if (numChars > 0) {
             hdr.write(size_t(numChars));
           }
diff --git a/proxy/http/HttpTransactHeaders.h b/proxy/http/HttpTransactHeaders.h
index 57d468f..848e557 100644
--- a/proxy/http/HttpTransactHeaders.h
+++ b/proxy/http/HttpTransactHeaders.h
@@ -64,7 +64,7 @@ public:
 
   enum class ProtocolStackDetail { Compact, Standard, Full };
 
-  static int write_hdr_protocol_stack(char *hdr_string, size_t len, ProtocolStackDetail pSDetail, ts::StringView *proto_buf,
+  static int write_hdr_protocol_stack(char *hdr_string, size_t len, ProtocolStackDetail pSDetail, ts::string_view *proto_buf,
                                       int n_proto, char separator = ' ');
 
   // Removing handle_conditional_headers.  Functionality appears to be elsewhere (issue_revalidate)
diff --git a/proxy/http2/Http2ClientSession.h b/proxy/http2/Http2ClientSession.h
index d81fdbc..427a760 100644
--- a/proxy/http2/Http2ClientSession.h
+++ b/proxy/http2/Http2ClientSession.h
@@ -260,7 +260,7 @@ public:
   }
 
   virtual int
-  populate_protocol(ts::StringView *result, int size) const override
+  populate_protocol(ts::string_view *result, int size) const override
   {
     int retval = 0;
     if (size > retval) {
@@ -273,12 +273,12 @@ public:
   }
 
   virtual const char *
-  protocol_contains(ts::StringView prefix) const override
+  protocol_contains(ts::string_view prefix) const override
   {
     const char *retval = nullptr;
 
-    if (prefix.size() <= IP_PROTO_TAG_HTTP_2_0.size() && strncmp(IP_PROTO_TAG_HTTP_2_0.ptr(), prefix.ptr(), prefix.size()) == 0) {
-      retval = IP_PROTO_TAG_HTTP_2_0.ptr();
+    if (prefix.size() <= IP_PROTO_TAG_HTTP_2_0.size() && strncmp(IP_PROTO_TAG_HTTP_2_0.data(), prefix.data(), prefix.size()) == 0) {
+      retval = IP_PROTO_TAG_HTTP_2_0.data();
     } else {
       retval = super::protocol_contains(prefix);
     }
diff --git a/proxy/logging/LogField.h b/proxy/logging/LogField.h
index 36b3ca8..0d41143 100644
--- a/proxy/logging/LogField.h
+++ b/proxy/logging/LogField.h
@@ -26,6 +26,7 @@
 
 #include "ts/ink_platform.h"
 #include "ts/List.h"
+#include <ts/TsBuffer.h>
 #include "LogFieldAliasMap.h"
 #include "Milestones.h"
 
diff --git a/proxy/logging/LogHost.cc b/proxy/logging/LogHost.cc
index 90dcf10..2200ef0 100644
--- a/proxy/logging/LogHost.cc
+++ b/proxy/logging/LogHost.cc
@@ -158,9 +158,9 @@ bool
 LogHost::set_name_or_ipstr(const char *name_or_ip)
 {
   if (name_or_ip && name_or_ip[0] != '\0') {
-    ts::ConstBuffer addr, port;
-    if (ats_ip_parse(ts::ConstBuffer(name_or_ip, strlen(name_or_ip)), &addr, &port) == 0) {
-      uint16_t p = port ? atoi(port.data()) : Log::config->collation_port;
+    ts::string_view addr, port;
+    if (ats_ip_parse(ts::string_view(name_or_ip), &addr, &port) == 0) {
+      uint16_t p = port.empty() ? Log::config->collation_port : atoi(port.data());
       char *n    = const_cast<char *>(addr.data());
       // Force termination. We know we can do this because the address
       // string is followed by either a nul or a colon.

-- 
To stop receiving notification emails like this one, please contact
['"commits@trafficserver.apache.org" <commits@trafficserver.apache.org>'].

Mime
View raw message