You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by rr...@apache.org on 2020/07/31 01:49:02 UTC
[trafficserver] branch master updated: constify Print() methods and
other low hanging fruit (#7068)
This is an automated email from the ASF dual-hosted git repository.
rrm 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 037ce51 constify Print() methods and other low hanging fruit (#7068)
037ce51 is described below
commit 037ce511d8042ed85008e32d383f8b5415eff13b
Author: Randall Meyer <rr...@apache.org>
AuthorDate: Thu Jul 30 18:48:55 2020 -0700
constify Print() methods and other low hanging fruit (#7068)
---
include/tscore/HostLookup.h | 9 +++++---
include/tscore/Tokenizer.h | 2 +-
include/tscore/Trie.h | 5 +++--
iocore/cache/CacheHosting.cc | 12 +++++-----
iocore/cache/P_CacheHosting.h | 15 ++++++++-----
iocore/dns/P_SplitDNSProcessor.h | 2 +-
iocore/dns/SplitDNS.cc | 2 +-
proxy/CacheControl.cc | 4 ++--
proxy/CacheControl.h | 4 ++--
proxy/ControlBase.cc | 4 +---
proxy/ControlBase.h | 5 ++++-
proxy/ControlMatcher.cc | 26 +++++++++++-----------
proxy/ControlMatcher.h | 37 +++++++++++++++++++------------
proxy/IPAllow.cc | 4 ++--
proxy/IPAllow.h | 5 +++--
proxy/ParentSelection.cc | 6 +----
proxy/ParentSelection.h | 4 +++-
proxy/hdrs/URL.h | 39 ++++++++++++++++++---------------
proxy/http/remap/UrlMapping.cc | 2 +-
proxy/http/remap/UrlMapping.h | 2 +-
proxy/http/remap/UrlMappingPathIndex.cc | 3 ++-
proxy/http/remap/UrlMappingPathIndex.h | 2 +-
proxy/http/remap/UrlRewrite.cc | 4 ++--
proxy/http/remap/UrlRewrite.h | 4 ++--
src/tscore/HostLookup.cc | 6 ++---
src/tscore/Tokenizer.cc | 9 ++++----
26 files changed, 120 insertions(+), 97 deletions(-)
diff --git a/include/tscore/HostLookup.h b/include/tscore/HostLookup.h
index 1d5bdb7..e5135d8 100644
--- a/include/tscore/HostLookup.h
+++ b/include/tscore/HostLookup.h
@@ -129,8 +129,9 @@ public:
bool Match(std::string_view host, void **opaque_ptr);
bool MatchFirst(std::string_view host, HostLookupState *s, void **opaque_ptr);
bool MatchNext(HostLookupState *s, void **opaque_ptr);
- void Print(PrintFunc const &f);
- void Print();
+
+ void Print(PrintFunc const &f) const;
+ void Print() const;
LeafArray *
get_leaf_array()
@@ -147,7 +148,9 @@ private:
HostBranch *InsertBranch(HostBranch *insert_in, std::string_view level_data);
HostBranch *FindNextLevel(HostBranch *from, std::string_view level_data, bool bNotProcess = false);
bool MatchArray(HostLookupState *s, void **opaque_ptr, LeafIndices &array, bool host_done);
- void PrintHostBranch(HostBranch *hb, PrintFunc const &f);
+
+ void PrintHostBranch(const HostBranch *hb, PrintFunc const &f) const;
+
HostBranch root; // The top of the search tree
LeafArray leaf_array; // array of all leaves in tree
std::string matcher_name; // Used for Debug/Warning/Error messages
diff --git a/include/tscore/Tokenizer.h b/include/tscore/Tokenizer.h
index a86c96a..c073d45 100644
--- a/include/tscore/Tokenizer.h
+++ b/include/tscore/Tokenizer.h
@@ -143,7 +143,7 @@ public:
};
unsigned count() const;
- void Print(); // Debugging print out
+ void Print() const;
inkcoreapi const char *iterFirst(tok_iter_state *state);
inkcoreapi const char *iterNext(tok_iter_state *state);
diff --git a/include/tscore/Trie.h b/include/tscore/Trie.h
index bf31a1a..67f5d93 100644
--- a/include/tscore/Trie.h
+++ b/include/tscore/Trie.h
@@ -20,6 +20,7 @@
See the License for the specific language governing permissions and
limitations under the License.
*/
+
#pragma once
#include <cstdio>
@@ -42,7 +43,7 @@ public:
// will return false if not found; else value_ptr will point to found value
T *Search(const char *key, int key_len = -1) const;
void Clear();
- void Print();
+ void Print() const;
bool
Empty() const
@@ -229,7 +230,7 @@ Trie<T>::Clear()
template <typename T>
void
-Trie<T>::Print()
+Trie<T>::Print() const
{
// The class we contain must provide a ::Print() method.
forl_LL(T, iter, m_value_list) iter->Print();
diff --git a/iocore/cache/CacheHosting.cc b/iocore/cache/CacheHosting.cc
index f8080bc..41c9957 100644
--- a/iocore/cache/CacheHosting.cc
+++ b/iocore/cache/CacheHosting.cc
@@ -53,7 +53,7 @@ CacheHostMatcher::~CacheHostMatcher()
// Debugging Method
//
void
-CacheHostMatcher::Print()
+CacheHostMatcher::Print() const
{
printf("\tHost/Domain Matcher with %d elements\n", num_el);
host_lookup->Print(PrintFunc);
@@ -96,7 +96,7 @@ CacheHostMatcher::AllocateSpace(int num_entries)
// arg hostname
//
void
-CacheHostMatcher::Match(const char *rdata, int rlen, CacheHostResult *result)
+CacheHostMatcher::Match(const char *rdata, int rlen, CacheHostResult *result) const
{
void *opaque_ptr;
CacheHostRecord *data_ptr;
@@ -111,6 +111,7 @@ CacheHostMatcher::Match(const char *rdata, int rlen, CacheHostResult *result)
if (rlen == 0) {
return;
}
+
char *data = static_cast<char *>(ats_malloc(rlen + 1));
memcpy(data, rdata, rlen);
*(data + rlen) = '\0';
@@ -208,7 +209,7 @@ CacheHostTable::~CacheHostTable()
// Debugging method
//
void
-CacheHostTable::Print()
+CacheHostTable::Print() const
{
printf("Control Matcher Table: %s\n", matcher_name);
if (hostMatch != nullptr) {
@@ -222,7 +223,7 @@ CacheHostTable::Print()
// Queries each table for the Result*
//
void
-CacheHostTable::Match(const char *rdata, int rlen, CacheHostResult *result)
+CacheHostTable::Match(const char *rdata, int rlen, CacheHostResult *result) const
{
hostMatch->Match(rdata, rlen, result);
}
@@ -272,6 +273,7 @@ CacheHostTable::BuildTableFromString(const char *config_file_path, char *file_bu
}
return 0;
}
+
// First get the number of entries
tmp = bufTok.iterFirst(&i_state);
while (tmp != nullptr) {
@@ -587,7 +589,7 @@ CacheHostRecord::UpdateMatch(CacheHostResult *r, char * /* rd ATS_UNUSED */)
}
void
-CacheHostRecord::Print()
+CacheHostRecord::Print() const
{
}
diff --git a/iocore/cache/P_CacheHosting.h b/iocore/cache/P_CacheHosting.h
index ba4af9b..e6eaa76 100644
--- a/iocore/cache/P_CacheHosting.h
+++ b/iocore/cache/P_CacheHosting.h
@@ -37,8 +37,10 @@ struct Cache;
struct CacheHostRecord {
int Init(CacheType typ);
int Init(matcher_line *line_info, CacheType typ);
+
void UpdateMatch(CacheHostResult *r, char *rd);
- void Print();
+ void Print() const;
+
~CacheHostRecord()
{
ats_free(vols);
@@ -72,10 +74,11 @@ public:
CacheHostMatcher(const char *name, CacheType typ);
~CacheHostMatcher();
- void Match(const char *rdata, int rlen, CacheHostResult *result);
void AllocateSpace(int num_entries);
void NewEntry(matcher_line *line_info);
- void Print();
+
+ void Match(const char *rdata, int rlen, CacheHostResult *result) const;
+ void Print() const;
int
getNumElements() const
@@ -109,10 +112,12 @@ public:
// object is
CacheHostTable(Cache *c, CacheType typ);
~CacheHostTable();
+
int BuildTable(const char *config_file_path);
int BuildTableFromString(const char *config_file_path, char *str);
- void Match(const char *rdata, int rlen, CacheHostResult *result);
- void Print();
+
+ void Match(const char *rdata, int rlen, CacheHostResult *result) const;
+ void Print() const;
int
getEntryCount() const
diff --git a/iocore/dns/P_SplitDNSProcessor.h b/iocore/dns/P_SplitDNSProcessor.h
index e91923b..e8ab998 100644
--- a/iocore/dns/P_SplitDNSProcessor.h
+++ b/iocore/dns/P_SplitDNSProcessor.h
@@ -193,7 +193,7 @@ public:
const char *ProcessDefDomain(char *val);
void UpdateMatch(SplitDNSResult *result, RequestData *rdata);
- void Print();
+ void Print() const;
DNSServer m_servers;
int m_dnsSrvr_cnt = 0;
diff --git a/iocore/dns/SplitDNS.cc b/iocore/dns/SplitDNS.cc
index 28babca..8af72da 100644
--- a/iocore/dns/SplitDNS.cc
+++ b/iocore/dns/SplitDNS.cc
@@ -531,7 +531,7 @@ SplitDNSRecord::UpdateMatch(SplitDNSResult *result, RequestData * /* rdata ATS_U
SplitDNSRecord::Print()
-------------------------------------------------------------- */
void
-SplitDNSRecord::Print()
+SplitDNSRecord::Print() const
{
for (int i = 0; i < m_dnsSrvr_cnt; i++) {
char ab[INET6_ADDRPORTSTRLEN];
diff --git a/proxy/CacheControl.cc b/proxy/CacheControl.cc
index 5a0a229..91749f1 100644
--- a/proxy/CacheControl.cc
+++ b/proxy/CacheControl.cc
@@ -184,7 +184,7 @@ getCacheControl(CacheControlResult *result, HttpRequestData *rdata, const Overri
// Debugging Method
//
void
-CacheControlResult::Print()
+CacheControlResult::Print() const
{
printf("\t reval: %d, never-cache: %d, pin: %d, ignore-c: %d ignore-s: %d\n", revalidate_after, never_cache, pin_in_cache_for,
ignore_client_no_cache, ignore_server_no_cache);
@@ -195,7 +195,7 @@ CacheControlResult::Print()
// Debugging Method
//
void
-CacheControlRecord::Print()
+CacheControlRecord::Print() const
{
switch (this->directive) {
case CC_REVALIDATE_AFTER:
diff --git a/proxy/CacheControl.h b/proxy/CacheControl.h
index e6730c6..f3395e3 100644
--- a/proxy/CacheControl.h
+++ b/proxy/CacheControl.h
@@ -63,7 +63,7 @@ class CacheControlResult
{
public:
inkcoreapi CacheControlResult();
- void Print();
+ void Print() const;
// Data for external use
//
@@ -109,7 +109,7 @@ public:
int cache_responses_to_cookies = -1;
Result Init(matcher_line *line_info);
inkcoreapi void UpdateMatch(CacheControlResult *result, RequestData *rdata);
- void Print();
+ void Print() const;
};
inline CacheControlRecord::CacheControlRecord() : ControlBase() {}
diff --git a/proxy/ControlBase.cc b/proxy/ControlBase.cc
index be0d47f..36c8b93 100644
--- a/proxy/ControlBase.cc
+++ b/proxy/ControlBase.cc
@@ -694,10 +694,8 @@ ControlBase::clear()
_mods.clear();
}
-// static const modifier_el default_el = { MOD_INVALID, NULL };
-
void
-ControlBase::Print()
+ControlBase::Print() const
{
int n = _mods.size();
diff --git a/proxy/ControlBase.h b/proxy/ControlBase.h
index 715b214..5beb88b 100644
--- a/proxy/ControlBase.h
+++ b/proxy/ControlBase.h
@@ -74,10 +74,13 @@ public:
ControlBase();
~ControlBase();
+
const char *ProcessModifiers(matcher_line *line_info);
bool CheckModifiers(HttpRequestData *request_data);
bool CheckForMatch(HttpRequestData *request_data, int last_number);
- void Print();
+
+ void Print() const;
+
int line_num = 0;
Modifier *findModOfType(Modifier::Type t) const;
diff --git a/proxy/ControlMatcher.cc b/proxy/ControlMatcher.cc
index 9695457..ec94609 100644
--- a/proxy/ControlMatcher.cc
+++ b/proxy/ControlMatcher.cc
@@ -105,7 +105,7 @@ template <class Data, class MatchResult> HostMatcher<Data, MatchResult>::~HostMa
//
template <class Data, class MatchResult>
void
-HostMatcher<Data, MatchResult>::Print()
+HostMatcher<Data, MatchResult>::Print() const
{
printf("\tHost/Domain Matcher with %d elements\n", num_el);
host_lookup->Print(PrintFunc);
@@ -150,7 +150,7 @@ HostMatcher<Data, MatchResult>::AllocateSpace(int num_entries)
//
template <class Data, class MatchResult>
void
-HostMatcher<Data, MatchResult>::Match(RequestData *rdata, MatchResult *result)
+HostMatcher<Data, MatchResult>::Match(RequestData *rdata, MatchResult *result) const
{
void *opaque_ptr;
Data *data_ptr;
@@ -256,7 +256,7 @@ template <class Data, class MatchResult> UrlMatcher<Data, MatchResult>::~UrlMatc
//
template <class Data, class MatchResult>
void
-UrlMatcher<Data, MatchResult>::Print()
+UrlMatcher<Data, MatchResult>::Print() const
{
printf("\tUrl Matcher with %d elements\n", num_el);
for (int i = 0; i < num_el; i++) {
@@ -335,7 +335,7 @@ UrlMatcher<Data, MatchResult>::NewEntry(matcher_line *line_info)
//
template <class Data, class MatchResult>
void
-UrlMatcher<Data, MatchResult>::Match(RequestData *rdata, MatchResult *result)
+UrlMatcher<Data, MatchResult>::Match(RequestData *rdata, MatchResult *result) const
{
char *url_str;
@@ -383,13 +383,13 @@ template <class Data, class MatchResult> RegexMatcher<Data, MatchResult>::~Regex
}
//
-// void RegexMatcher<Data,MatchResult>::Print()
+// void RegexMatcher<Data,MatchResult>::Print() const
//
// Debugging function
//
template <class Data, class MatchResult>
void
-RegexMatcher<Data, MatchResult>::Print()
+RegexMatcher<Data, MatchResult>::Print() const
{
printf("\tRegex Matcher with %d elements\n", num_el);
for (int i = 0; i < num_el; i++) {
@@ -482,7 +482,7 @@ RegexMatcher<Data, MatchResult>::NewEntry(matcher_line *line_info)
//
template <class Data, class MatchResult>
void
-RegexMatcher<Data, MatchResult>::Match(RequestData *rdata, MatchResult *result)
+RegexMatcher<Data, MatchResult>::Match(RequestData *rdata, MatchResult *result) const
{
char *url_str;
int r;
@@ -535,7 +535,7 @@ HostRegexMatcher<Data, MatchResult>::HostRegexMatcher(const char *name, const ch
//
template <class Data, class MatchResult>
void
-HostRegexMatcher<Data, MatchResult>::Match(RequestData *rdata, MatchResult *result)
+HostRegexMatcher<Data, MatchResult>::Match(RequestData *rdata, MatchResult *result) const
{
const char *url_str;
int r;
@@ -649,7 +649,7 @@ IpMatcher<Data, MatchResult>::NewEntry(matcher_line *line_info)
//
template <class Data, class MatchResult>
void
-IpMatcher<Data, MatchResult>::Match(sockaddr const *addr, RequestData *rdata, MatchResult *result)
+IpMatcher<Data, MatchResult>::Match(sockaddr const *addr, RequestData *rdata, MatchResult *result) const
{
void *raw;
if (ip_map.contains(addr, &raw)) {
@@ -661,7 +661,7 @@ IpMatcher<Data, MatchResult>::Match(sockaddr const *addr, RequestData *rdata, Ma
template <class Data, class MatchResult>
void
-IpMatcher<Data, MatchResult>::Print()
+IpMatcher<Data, MatchResult>::Print() const
{
printf("\tIp Matcher with %d elements, %zu ranges.\n", num_el, ip_map.count());
for (IpMap::iterator spot(ip_map.begin()), limit(ip_map.end()); spot != limit; ++spot) {
@@ -718,7 +718,7 @@ template <class Data, class MatchResult> ControlMatcher<Data, MatchResult>::~Con
//
template <class Data, class MatchResult>
void
-ControlMatcher<Data, MatchResult>::Print()
+ControlMatcher<Data, MatchResult>::Print() const
{
printf("Control Matcher Table: %s\n", matcher_name);
if (hostMatch != nullptr) {
@@ -739,13 +739,13 @@ ControlMatcher<Data, MatchResult>::Print()
}
// void ControlMatcher<Data, MatchResult>::Match(RequestData* rdata
-// MatchResult* result)
+// MatchResult* result) const
//
// Queries each table for the MatchResult*
//
template <class Data, class MatchResult>
void
-ControlMatcher<Data, MatchResult>::Match(RequestData *rdata, MatchResult *result)
+ControlMatcher<Data, MatchResult>::Match(RequestData *rdata, MatchResult *result) const
{
if (hostMatch != nullptr) {
hostMatch->Match(rdata, result);
diff --git a/proxy/ControlMatcher.h b/proxy/ControlMatcher.h
index 50cb291..145e958 100644
--- a/proxy/ControlMatcher.h
+++ b/proxy/ControlMatcher.h
@@ -183,10 +183,12 @@ template <class Data, class MatchResult> class UrlMatcher : protected BaseMatche
public:
UrlMatcher(const char *name, const char *filename);
~UrlMatcher();
- void Match(RequestData *rdata, MatchResult *result);
+
void AllocateSpace(int num_entries);
Result NewEntry(matcher_line *line_info);
- void Print();
+
+ void Match(RequestData *rdata, MatchResult *result) const;
+ void Print() const;
using super::num_el;
using super::matcher_name;
@@ -207,10 +209,12 @@ template <class Data, class MatchResult> class RegexMatcher : protected BaseMatc
public:
RegexMatcher(const char *name, const char *filename);
~RegexMatcher();
- void Match(RequestData *rdata, MatchResult *result);
+
void AllocateSpace(int num_entries);
Result NewEntry(matcher_line *line_info);
- void Print();
+
+ void Match(RequestData *rdata, MatchResult *result) const;
+ void Print() const;
using super::num_el;
using super::matcher_name;
@@ -229,7 +233,7 @@ template <class Data, class MatchResult> class HostRegexMatcher : public RegexMa
public:
HostRegexMatcher(const char *name, const char *filename);
- void Match(RequestData *rdata, MatchResult *result);
+ void Match(RequestData *rdata, MatchResult *result) const;
using super::num_el;
using super::matcher_name;
@@ -245,10 +249,12 @@ template <class Data, class MatchResult> class HostMatcher : protected BaseMatch
public:
HostMatcher(const char *name, const char *filename);
~HostMatcher();
- void Match(RequestData *rdata, MatchResult *result);
+
void AllocateSpace(int num_entries);
Result NewEntry(matcher_line *line_info);
- void Print();
+
+ void Match(RequestData *rdata, MatchResult *result) const;
+ void Print() const;
using super::num_el;
using super::matcher_name;
@@ -273,10 +279,12 @@ template <class Data, class MatchResult> class IpMatcher : protected BaseMatcher
public:
IpMatcher(const char *name, const char *filename);
- void Match(sockaddr const *ip_addr, RequestData *rdata, MatchResult *result);
+
void AllocateSpace(int num_entries);
Result NewEntry(matcher_line *line_info);
- void Print();
+
+ void Match(sockaddr const *ip_addr, RequestData *rdata, MatchResult *result) const;
+ void Print() const;
using super::num_el;
using super::matcher_name;
@@ -299,18 +307,19 @@ private:
template <class Data, class MatchResult> class ControlMatcher
{
public:
- // Parameter name must not be deallocated before this
- // object is
+ // Parameter name must not be deallocated before this object is
ControlMatcher(const char *file_var, const char *name, const matcher_tags *tags,
int flags_in = (ALLOW_HOST_TABLE | ALLOW_IP_TABLE | ALLOW_REGEX_TABLE | ALLOW_HOST_REGEX_TABLE | ALLOW_URL_TABLE));
~ControlMatcher();
+
int BuildTable();
int BuildTableFromString(char *str);
- void Match(RequestData *rdata, MatchResult *result);
- void Print();
+
+ void Match(RequestData *rdata, MatchResult *result) const;
+ void Print() const;
int
- getEntryCount()
+ getEntryCount() const
{
return m_numEntries;
}
diff --git a/proxy/IPAllow.cc b/proxy/IPAllow.cc
index 776c8b5..655c251 100644
--- a/proxy/IPAllow.cc
+++ b/proxy/IPAllow.cc
@@ -196,7 +196,7 @@ IpAllow::match(sockaddr const *ip, match_key_t key)
IpAllow::IpAllow(const char *config_var) : config_file(ats_scoped_str(RecConfigReadConfigPath(config_var)).get()) {}
void
-IpAllow::PrintMap(IpMap *map)
+IpAllow::PrintMap(const IpMap *map) const
{
std::ostringstream s;
s << map->count() << " ACL entries.";
@@ -243,7 +243,7 @@ IpAllow::PrintMap(IpMap *map)
}
void
-IpAllow::Print()
+IpAllow::Print() const
{
Debug("ip-allow", "Printing src map");
PrintMap(&_src_map);
diff --git a/proxy/IPAllow.h b/proxy/IPAllow.h
index 5656a5c..9221e75 100644
--- a/proxy/IPAllow.h
+++ b/proxy/IPAllow.h
@@ -147,7 +147,7 @@ public:
explicit IpAllow(const char *config_var);
- void Print();
+ void Print() const;
static ACL match(sockaddr const *ip, match_key_t key);
static ACL match(IpEndpoint const *ip, match_key_t key);
@@ -187,7 +187,8 @@ private:
static const Record ALLOW_ALL_RECORD; ///< Static record that allows all access.
static bool accept_check_p; ///< @c true if deny all can be enforced during accept.
- void PrintMap(IpMap *map);
+ void PrintMap(const IpMap *map) const;
+
int BuildTable();
int ATSBuildTable(const std::string &);
int YAMLBuildTable(const std::string &);
diff --git a/proxy/ParentSelection.cc b/proxy/ParentSelection.cc
index ec2d144..08254a4 100644
--- a/proxy/ParentSelection.cc
+++ b/proxy/ParentSelection.cc
@@ -300,10 +300,6 @@ ParentConfig::reconfigure()
Note("%s finished loading", ts::filename::PARENT);
}
-// void ParentConfig::print
-//
-// Debugging function
-//
void
ParentConfig::print()
{
@@ -862,7 +858,7 @@ ParentRecord::~ParentRecord()
}
void
-ParentRecord::Print()
+ParentRecord::Print() const
{
printf("\t\t");
for (int i = 0; i < num_parents; i++) {
diff --git a/proxy/ParentSelection.h b/proxy/ParentSelection.h
index 1e46485..d9cf6e8 100644
--- a/proxy/ParentSelection.h
+++ b/proxy/ParentSelection.h
@@ -136,7 +136,9 @@ public:
Result Init(matcher_line *line_info);
bool DefaultInit(char *val);
void UpdateMatch(ParentResult *result, RequestData *rdata);
- void Print();
+
+ void Print() const;
+
pRecord *parents = nullptr;
pRecord *secondary_parents = nullptr;
int num_parents = 0;
diff --git a/proxy/hdrs/URL.h b/proxy/hdrs/URL.h
index 025d2db..36f52aa 100644
--- a/proxy/hdrs/URL.h
+++ b/proxy/hdrs/URL.h
@@ -238,19 +238,21 @@ public:
// Note that URL::destroy() is inherited from HdrHeapSDKHandle.
void nuke_proxy_stuff();
- int print(char *buf, int bufsize, int *bufindex, int *dumpoffset, bool normalized = false);
+ int print(char *buf, int bufsize, int *bufindex, int *dumpoffset, bool normalized = false) const;
+
+ int length_get() const;
- int length_get();
void clear_string_ref();
- char *string_get(Arena *arena, int *length = nullptr, bool normalized = false);
- char *string_get_ref(int *length = nullptr, bool normalized = false);
- char *string_get_buf(char *dstbuf, int dsbuf_size, int *length = nullptr);
+
+ char *string_get(Arena *arena, int *length = nullptr, bool normalized = false) const;
+ char *string_get_ref(int *length = nullptr, bool normalized = false) const;
+ char *string_get_buf(char *dstbuf, int dsbuf_size, int *length = nullptr) const;
void hash_get(CryptoHash *hash, cache_generation_t generation = -1) const;
- void host_hash_get(CryptoHash *hash);
+ void host_hash_get(CryptoHash *hash) const;
const char *scheme_get(int *length);
const std::string_view scheme_get();
- int scheme_get_wksidx();
+ int scheme_get_wksidx() const;
void scheme_set(const char *value, int length);
const char *user_get(int *length);
@@ -259,8 +261,9 @@ public:
void password_set(const char *value, int length);
const char *host_get(int *length);
void host_set(const char *value, int length);
- int port_get();
- int port_get_raw();
+
+ int port_get() const;
+ int port_get_raw() const;
void port_set(int port);
const char *path_get(int *length);
@@ -372,7 +375,7 @@ URL::nuke_proxy_stuff()
-------------------------------------------------------------------------*/
inline int
-URL::print(char *buf, int bufsize, int *bufindex, int *dumpoffset, bool normalized)
+URL::print(char *buf, int bufsize, int *bufindex, int *dumpoffset, bool normalized) const
{
ink_assert(valid());
return url_print(m_url_impl, buf, bufsize, bufindex, dumpoffset, normalized);
@@ -382,7 +385,7 @@ URL::print(char *buf, int bufsize, int *bufindex, int *dumpoffset, bool normaliz
-------------------------------------------------------------------------*/
inline int
-URL::length_get()
+URL::length_get() const
{
ink_assert(valid());
return url_length_get(m_url_impl);
@@ -392,14 +395,14 @@ URL::length_get()
-------------------------------------------------------------------------*/
inline char *
-URL::string_get(Arena *arena_or_null_for_malloc, int *length, bool normalized)
+URL::string_get(Arena *arena_or_null_for_malloc, int *length, bool normalized) const
{
ink_assert(valid());
return url_string_get(m_url_impl, arena_or_null_for_malloc, length, m_heap, normalized);
}
inline char *
-URL::string_get_ref(int *length, bool normalized)
+URL::string_get_ref(int *length, bool normalized) const
{
ink_assert(valid());
return url_string_get_ref(m_heap, m_url_impl, length, normalized);
@@ -416,7 +419,7 @@ URL::clear_string_ref()
/*-------------------------------------------------------------------------
-------------------------------------------------------------------------*/
inline char *
-URL::string_get_buf(char *dstbuf, int dsbuf_size, int *length)
+URL::string_get_buf(char *dstbuf, int dsbuf_size, int *length) const
{
ink_assert(valid());
return url_string_get_buf(m_url_impl, dstbuf, dsbuf_size, length);
@@ -436,7 +439,7 @@ URL::hash_get(CryptoHash *hash, cache_generation_t generation) const
-------------------------------------------------------------------------*/
inline void
-URL::host_hash_get(CryptoHash *hash)
+URL::host_hash_get(CryptoHash *hash) const
{
ink_assert(valid());
url_host_CryptoHash_get(m_url_impl, hash);
@@ -467,7 +470,7 @@ URL::scheme_get(int *length)
}
inline int
-URL::scheme_get_wksidx()
+URL::scheme_get_wksidx() const
{
ink_assert(valid());
return (m_url_impl->m_scheme_wks_idx);
@@ -551,7 +554,7 @@ URL::host_set(const char *value, int length)
-------------------------------------------------------------------------*/
inline int
-URL::port_get()
+URL::port_get() const
{
ink_assert(valid());
return url_canonicalize_port(m_url_impl->m_url_type, m_url_impl->m_port);
@@ -561,7 +564,7 @@ URL::port_get()
-------------------------------------------------------------------------*/
inline int
-URL::port_get_raw()
+URL::port_get_raw() const
{
ink_assert(valid());
return m_url_impl->m_port;
diff --git a/proxy/http/remap/UrlMapping.cc b/proxy/http/remap/UrlMapping.cc
index d592cef..4f1494b 100644
--- a/proxy/http/remap/UrlMapping.cc
+++ b/proxy/http/remap/UrlMapping.cc
@@ -84,7 +84,7 @@ url_mapping::~url_mapping()
}
void
-url_mapping::Print()
+url_mapping::Print() const
{
char from_url_buf[131072], to_url_buf[131072];
diff --git a/proxy/http/remap/UrlMapping.h b/proxy/http/remap/UrlMapping.h
index 2fa52be..a0482c1 100644
--- a/proxy/http/remap/UrlMapping.h
+++ b/proxy/http/remap/UrlMapping.h
@@ -92,7 +92,7 @@ public:
return _plugin_inst_list.size();
}
- void Print();
+ void Print() const;
int from_path_len = 0;
URL fromURL;
diff --git a/proxy/http/remap/UrlMappingPathIndex.cc b/proxy/http/remap/UrlMappingPathIndex.cc
index f7b5021..95a47ed 100644
--- a/proxy/http/remap/UrlMappingPathIndex.cc
+++ b/proxy/http/remap/UrlMappingPathIndex.cc
@@ -20,6 +20,7 @@
See the License for the specific language governing permissions and
limitations under the License.
*/
+
#include "UrlMappingPathIndex.h"
UrlMappingPathIndex::~UrlMappingPathIndex()
@@ -84,7 +85,7 @@ lFail:
}
void
-UrlMappingPathIndex::Print()
+UrlMappingPathIndex::Print() const
{
for (auto &m_trie : m_tries) {
m_trie.second->Print();
diff --git a/proxy/http/remap/UrlMappingPathIndex.h b/proxy/http/remap/UrlMappingPathIndex.h
index 290690d..6e4febc 100644
--- a/proxy/http/remap/UrlMappingPathIndex.h
+++ b/proxy/http/remap/UrlMappingPathIndex.h
@@ -37,7 +37,7 @@ public:
virtual ~UrlMappingPathIndex();
bool Insert(url_mapping *mapping);
url_mapping *Search(URL *request_url, int request_port, bool normal_search = true) const;
- void Print();
+ void Print() const;
private:
typedef Trie<url_mapping> UrlMappingTrie;
diff --git a/proxy/http/remap/UrlRewrite.cc b/proxy/http/remap/UrlRewrite.cc
index aab1b21..1724943 100644
--- a/proxy/http/remap/UrlRewrite.cc
+++ b/proxy/http/remap/UrlRewrite.cc
@@ -140,7 +140,7 @@ UrlRewrite::_destroyTable(std::unique_ptr<URLTable> &h_table)
/** Debugging Method. */
void
-UrlRewrite::Print()
+UrlRewrite::Print() const
{
printf("URL Rewrite table with %d entries\n", num_rules_forward + num_rules_reverse + num_rules_redirect_temporary +
num_rules_redirect_permanent + num_rules_forward_with_recv_port);
@@ -168,7 +168,7 @@ UrlRewrite::Print()
/** Debugging method. */
void
-UrlRewrite::PrintStore(MappingsStore &store)
+UrlRewrite::PrintStore(const MappingsStore &store) const
{
if (store.hash_lookup) {
for (auto &it : *store.hash_lookup) {
diff --git a/proxy/http/remap/UrlRewrite.h b/proxy/http/remap/UrlRewrite.h
index 7419edd..8567857 100644
--- a/proxy/http/remap/UrlRewrite.h
+++ b/proxy/http/remap/UrlRewrite.h
@@ -81,7 +81,7 @@ public:
mapping_type Remap_redirect(HTTPHdr *request_header, URL *redirect_url);
bool ReverseMap(HTTPHdr *response_header);
void SetReverseFlag(int flag);
- void Print();
+ void Print() const;
// The UrlRewrite object is-a RefCountObj, but this is a convenience to make it clear that we
// don't delete() these objects directly, but via the release() method only.
@@ -145,7 +145,7 @@ public:
};
void PerformACLFiltering(HttpTransact::State *s, url_mapping *mapping);
- void PrintStore(MappingsStore &store);
+ void PrintStore(const MappingsStore &store) const;
void
DestroyStore(MappingsStore &store)
diff --git a/src/tscore/HostLookup.cc b/src/tscore/HostLookup.cc
index b70a45a..b695e0f 100644
--- a/src/tscore/HostLookup.cc
+++ b/src/tscore/HostLookup.cc
@@ -587,13 +587,13 @@ HostBranch::~HostBranch()
HostLookup::HostLookup(string_view name) : matcher_name(name) {}
void
-HostLookup::Print()
+HostLookup::Print() const
{
Print([](void *) -> void {});
}
void
-HostLookup::Print(PrintFunc const &f)
+HostLookup::Print(PrintFunc const &f) const
{
PrintHostBranch(&root, f);
}
@@ -605,7 +605,7 @@ HostLookup::Print(PrintFunc const &f)
// and print out each element
//
void
-HostLookup::PrintHostBranch(HostBranch *hb, PrintFunc const &f)
+HostLookup::PrintHostBranch(const HostBranch *hb, PrintFunc const &f) const
{
for (auto curIndex : hb->leaf_indices) {
auto &leaf{leaf_array[curIndex]};
diff --git a/src/tscore/Tokenizer.cc b/src/tscore/Tokenizer.cc
index 7db0007..1800952 100644
--- a/src/tscore/Tokenizer.cc
+++ b/src/tscore/Tokenizer.cc
@@ -21,7 +21,6 @@
limitations under the License.
*/
-/***************************************/
#include "tscore/ink_platform.h"
#include "tscore/Tokenizer.h"
#include "tscore/ink_assert.h"
@@ -334,11 +333,11 @@ Tokenizer::iterNext(tok_iter_state *state)
}
void
-Tokenizer::Print()
+Tokenizer::Print() const
{
- tok_node *cur_node = &start_node;
- int node_index = 0;
- int count = 0;
+ const tok_node *cur_node = &start_node;
+ int node_index = 0;
+ int count = 0;
while (cur_node != nullptr) {
if (cur_node->el[node_index] != nullptr) {