From c8ab5ec6c34fbd6544cf8fac9fd6266e7651ffed Mon Sep 17 00:00:00 2001 From: Amos Jeffries Date: Tue, 12 Jun 2018 15:38:17 +0000 Subject: [PATCH] Bug 4791: Build failure on MacOS (#220) The src/URL.h and src/acl/Url.h files clash on MacOS case- insensitive filesystem. Resolve this and incorrect naming issue by moving class URL into the AnyP namespace as AnyP::Uri. --- src/HttpRequest.cc | 1 - src/HttpRequest.h | 4 +- src/Makefile.am | 27 ++++++------- src/acl/Asn.cc | 2 +- src/acl/DomainData.cc | 2 +- src/acl/ServerName.cc | 1 - src/acl/Url.cc | 1 - src/adaptation/ServiceConfig.cc | 2 +- src/adaptation/ecap/MessageRep.cc | 5 +-- src/adaptation/icap/ModXact.cc | 1 - src/anyp/Makefile.am | 2 + src/{url.cc => anyp/Uri.cc} | 26 ++++++------- src/{URL.h => anyp/Uri.h} | 45 +++++++++++++--------- src/anyp/forward.h | 1 + src/carp.cc | 1 - src/client_side.cc | 1 - src/client_side_reply.cc | 1 - src/client_side_request.cc | 3 +- src/clients/Client.cc | 1 - src/clients/FtpGateway.cc | 1 - src/errorpage.cc | 1 - src/external_acl.cc | 1 - src/format/Format.cc | 1 - src/htcp.cc | 1 - src/http.cc | 1 - src/icmp/net_db.cc | 2 +- src/icmp/net_db.h | 4 +- src/internal.cc | 3 +- src/main.cc | 1 - src/neighbors.cc | 5 +-- src/neighbors.h | 4 +- src/peer_select.cc | 1 - src/refresh.cc | 1 - src/servers/FtpServer.cc | 2 +- src/ssl/ServerBump.cc | 3 +- src/ssl/support.cc | 2 +- src/store_key_md5.cc | 1 - src/tests/Stub.list | 2 +- src/tests/{stub_url.cc => stub_libanyp.cc} | 22 +++++------ src/tests/stub_libicmp.cc | 2 +- src/tests/testURL.cc | 12 +++--- src/urn.cc | 3 +- 42 files changed, 93 insertions(+), 110 deletions(-) rename src/{url.cc => anyp/Uri.cc} (98%) rename src/{URL.h => anyp/Uri.h} (90%) rename src/tests/{stub_url.cc => stub_libanyp.cc} (70%) diff --git a/src/HttpRequest.cc b/src/HttpRequest.cc index 5a2417385e..375cd186aa 100644 --- a/src/HttpRequest.cc +++ b/src/HttpRequest.cc @@ -30,7 +30,6 @@ #include "sbuf/StringConvert.h" #include "SquidConfig.h" #include "Store.h" -#include "URL.h" #if USE_AUTH #include "auth/UserRequest.h" diff --git a/src/HttpRequest.h b/src/HttpRequest.h index a963883885..f8b7d4a8f7 100644 --- a/src/HttpRequest.h +++ b/src/HttpRequest.h @@ -9,6 +9,7 @@ #ifndef SQUID_HTTPREQUEST_H #define SQUID_HTTPREQUEST_H +#include "anyp/Uri.h" #include "base/CbcPointer.h" #include "dns/forward.h" #include "err_type.h" @@ -18,7 +19,6 @@ #include "MasterXaction.h" #include "Notes.h" #include "RequestFlags.h" -#include "URL.h" #if USE_AUTH #include "auth/UserRequest.h" @@ -100,7 +100,7 @@ protected: public: HttpRequestMethod method; - URL url; ///< the request URI + AnyP::Uri url; ///< the request URI private: #if USE_ADAPTATION diff --git a/src/Makefile.am b/src/Makefile.am index 050e7440f6..b3007da9b0 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -476,8 +476,6 @@ squid_SOURCES = \ tunnel.cc \ typedefs.h \ $(UNLINKDSOURCE) \ - url.cc \ - URL.h \ urn.h \ urn.cc \ wccp.h \ @@ -996,7 +994,7 @@ tests_testHttpReply_SOURCES=\ tests/testHttpReply.cc \ tests/testHttpReply.h \ tests/stub_time.cc \ - tests/stub_url.cc \ + tests/stub_libanyp.cc \ wordlist.h \ wordlist.cc nodist_tests_testHttpReply_SOURCES=\ @@ -1118,8 +1116,7 @@ tests_testACLMaxUserIP_SOURCES= \ tests/testACLMaxUserIP.cc \ tests/testACLMaxUserIP.h \ tests/stub_time.cc \ - tests/stub_url.cc \ - URL.h \ + tests/stub_libanyp.cc \ MemBuf.cc \ wordlist.h \ wordlist.cc @@ -1369,7 +1366,7 @@ tests_testCacheManager_SOURCES = \ tests/stub_SwapDir.cc \ MemStore.cc \ $(UNLINKDSOURCE) \ - tests/stub_url.cc \ + tests/stub_libanyp.cc \ urn.h \ urn.cc \ wccp2.h \ @@ -1551,7 +1548,7 @@ tests_testDiskIO_SOURCES = \ tests/testStoreSupport.h \ tests/stub_time.cc \ $(UNLINKDSOURCE) \ - tests/stub_url.cc \ + tests/stub_libanyp.cc \ $(WIN32_SOURCE) \ wordlist.h \ wordlist.cc \ @@ -1800,7 +1797,7 @@ tests_testEvent_SOURCES = \ tests/stub_tunnel.cc \ MemStore.cc \ $(UNLINKDSOURCE) \ - tests/stub_url.cc \ + tests/stub_libanyp.cc \ urn.h \ urn.cc \ wccp2.h \ @@ -2034,7 +2031,7 @@ tests_testEventLoop_SOURCES = \ tests/stub_tunnel.cc \ MemStore.cc \ $(UNLINKDSOURCE) \ - tests/stub_url.cc \ + tests/stub_libanyp.cc \ urn.h \ urn.cc \ wccp2.h \ @@ -2263,7 +2260,7 @@ tests_test_http_range_SOURCES = \ tools.cc \ tests/stub_tunnel.cc \ $(UNLINKDSOURCE) \ - tests/stub_url.cc \ + tests/stub_libanyp.cc \ urn.h \ urn.cc \ wccp2.h \ @@ -2368,7 +2365,7 @@ tests_testHttp1Parser_SOURCES = \ tests/testHttp1Parser.cc \ tests/testHttp1Parser.h \ tests/stub_time.cc \ - tests/stub_url.cc \ + tests/stub_libanyp.cc \ wordlist.h \ wordlist.cc nodist_tests_testHttp1Parser_SOURCES = \ @@ -2565,7 +2562,6 @@ tests_testHttpRequest_SOURCES = \ tests/stub_tunnel.cc \ tests/stub_SwapDir.cc \ MemStore.cc \ - url.cc \ urn.h \ urn.cc \ wccp2.h \ @@ -2801,7 +2797,7 @@ tests_testStore_SOURCES= \ tests/TestSwapDir.cc \ tests/TestSwapDir.h \ tests/stub_time.cc \ - tests/stub_url.cc \ + tests/stub_libanyp.cc \ wordlist.h \ wordlist.cc @@ -2998,7 +2994,7 @@ tests_testUfs_SOURCES = \ HttpHdrCc.cc \ HttpHdrSc.cc \ HttpHdrScTarget.cc \ - tests/stub_url.cc \ + tests/stub_libanyp.cc \ StatCounters.h \ StatCounters.cc \ StatHist.h \ @@ -3198,7 +3194,7 @@ tests_testRock_SOURCES = \ tools.h \ tests/stub_tools.cc \ time.cc \ - tests/stub_url.cc \ + tests/stub_libanyp.cc \ wordlist.h \ wordlist.cc \ $(DELAY_POOL_SOURCE) \ @@ -3424,7 +3420,6 @@ tests_testURL_SOURCES = \ tools.h \ tools.cc \ tests/stub_tunnel.cc \ - url.cc \ urn.h \ urn.cc \ wccp2.h \ diff --git a/src/acl/Asn.cc b/src/acl/Asn.cc index 57be1ab9d8..a40941c223 100644 --- a/src/acl/Asn.cc +++ b/src/acl/Asn.cc @@ -235,7 +235,7 @@ asnStats(StoreEntry * sentry) static void asnCacheStart(int as) { - // TODO: use class URL instead of generating a string and re-parsing + // TODO: use class AnyP::Uri instead of generating a string and re-parsing LOCAL_ARRAY(char, asres, 4096); StoreEntry *e; ASState *asState = new ASState; diff --git a/src/acl/DomainData.cc b/src/acl/DomainData.cc index 2100992138..13c15ba2fd 100644 --- a/src/acl/DomainData.cc +++ b/src/acl/DomainData.cc @@ -11,10 +11,10 @@ #include "squid.h" #include "acl/Checklist.h" #include "acl/DomainData.h" +#include "anyp/Uri.h" #include "cache_cf.h" #include "ConfigParser.h" #include "Debug.h" -#include "src/URL.h" #include "util.h" template diff --git a/src/acl/ServerName.cc b/src/acl/ServerName.cc index a01241ff2f..137c8968e6 100644 --- a/src/acl/ServerName.cc +++ b/src/acl/ServerName.cc @@ -22,7 +22,6 @@ #include "ssl/bio.h" #include "ssl/ServerBump.h" #include "ssl/support.h" -#include "URL.h" // Compare function for tree search algorithms static int diff --git a/src/acl/Url.cc b/src/acl/Url.cc index 7bd65d653c..442f15f08c 100644 --- a/src/acl/Url.cc +++ b/src/acl/Url.cc @@ -14,7 +14,6 @@ #include "acl/Url.h" #include "HttpRequest.h" #include "rfc1738.h" -#include "src/URL.h" int ACLUrlStrategy::match (ACLData * &data, ACLFilledChecklist *checklist) diff --git a/src/adaptation/ServiceConfig.cc b/src/adaptation/ServiceConfig.cc index 3c868f8240..17cd55c148 100644 --- a/src/adaptation/ServiceConfig.cc +++ b/src/adaptation/ServiceConfig.cc @@ -189,7 +189,7 @@ bool Adaptation::ServiceConfig::grokUri(const char *value) { // TODO: find core code that parses URLs and extracts various parts - // AYJ: most of this is duplicate of URL::parse() in src/url.cc + // AYJ: most of this is duplicate of AnyP::Uri::parse() if (!value || !*value) { debugs(3, DBG_CRITICAL, HERE << cfg_filename << ':' << config_lineno << ": " << diff --git a/src/adaptation/ecap/MessageRep.cc b/src/adaptation/ecap/MessageRep.cc index 682f6ef690..9b18ccee9e 100644 --- a/src/adaptation/ecap/MessageRep.cc +++ b/src/adaptation/ecap/MessageRep.cc @@ -20,7 +20,6 @@ #include "adaptation/ecap/MessageRep.h" #include "adaptation/ecap/XactionRep.h" #include "base/TextException.h" -#include "URL.h" /* HeaderRep */ @@ -203,8 +202,8 @@ Adaptation::Ecap::RequestLineRep::RequestLineRep(HttpRequest &aMessage): void Adaptation::Ecap::RequestLineRep::uri(const Area &aUri) { - // TODO: if method is not set, URL::parse will assume it is not connect; - // Can we change URL::parse API to remove the method parameter? + // TODO: if method is not set, AnyP::Uri::parse will assume it is not connect; + // Can we change AnyP::Uri::parse API to remove the method parameter? const char *buf = aUri.toString().c_str(); const bool ok = theMessage.url.parse(theMessage.method, buf); Must(ok); diff --git a/src/adaptation/icap/ModXact.cc b/src/adaptation/icap/ModXact.cc index 8a15e1be83..332ea5aeba 100644 --- a/src/adaptation/icap/ModXact.cc +++ b/src/adaptation/icap/ModXact.cc @@ -30,7 +30,6 @@ #include "HttpReply.h" #include "MasterXaction.h" #include "SquidTime.h" -#include "URL.h" // flow and terminology: // HTTP| --> receive --> encode --> write --> |network diff --git a/src/anyp/Makefile.am b/src/anyp/Makefile.am index 6bd41e5d58..a662ae2b9d 100644 --- a/src/anyp/Makefile.am +++ b/src/anyp/Makefile.am @@ -18,6 +18,8 @@ libanyp_la_SOURCES = \ ProtocolType.h \ ProtocolVersion.h \ TrafficMode.h \ + Uri.cc \ + Uri.h \ UriScheme.cc \ UriScheme.h diff --git a/src/url.cc b/src/anyp/Uri.cc similarity index 98% rename from src/url.cc rename to src/anyp/Uri.cc index 44b61522a2..30af7eedaf 100644 --- a/src/url.cc +++ b/src/anyp/Uri.cc @@ -9,12 +9,12 @@ /* DEBUG: section 23 URL Parsing */ #include "squid.h" +#include "anyp/Uri.h" #include "globals.h" #include "HttpRequest.h" #include "rfc1738.h" #include "SquidConfig.h" #include "SquidString.h" -#include "URL.h" static const char valid_hostname_chars_u[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" @@ -30,21 +30,21 @@ static const char valid_hostname_chars[] = ; const SBuf & -URL::Asterisk() +AnyP::Uri::Asterisk() { static SBuf star("*"); return star; } const SBuf & -URL::SlashPath() +AnyP::Uri::SlashPath() { static SBuf slash("/"); return slash; } void -URL::host(const char *src) +AnyP::Uri::host(const char *src) { hostAddr_.setEmpty(); hostAddr_ = src; @@ -60,7 +60,7 @@ URL::host(const char *src) } const SBuf & -URL::path() const +AnyP::Uri::path() const { // RFC 3986 section 3.3 says path can be empty (path-abempty). // RFC 7230 sections 2.7.3, 5.3.1, 5.7.2 - says path cannot be empty, default to "/" @@ -188,7 +188,7 @@ urlParseProtocol(const char *b) * being "end of host with implied path of /". */ bool -URL::parse(const HttpRequestMethod& method, const char *url) +AnyP::Uri::parse(const HttpRequestMethod& method, const char *url) { LOCAL_ARRAY(char, proto, MAX_URL); LOCAL_ARRAY(char, login, MAX_URL); @@ -224,7 +224,7 @@ URL::parse(const HttpRequestMethod& method, const char *url) return false; } else if ((method == Http::METHOD_OPTIONS || method == Http::METHOD_TRACE) && - URL::Asterisk().cmp(url) == 0) { + AnyP::Uri::Asterisk().cmp(url) == 0) { parseFinish(AnyP::PROTO_HTTP, nullptr, url, foundHost, SBuf(), 80 /* HTTP default port */); return true; } else if (strncmp(url, "urn:", 4) == 0) { @@ -444,7 +444,7 @@ URL::parse(const HttpRequestMethod& method, const char *url) /// Update the URL object with parsed URI data. void -URL::parseFinish(const AnyP::ProtocolType protocol, +AnyP::Uri::parseFinish(const AnyP::ProtocolType protocol, const char *const protoStr, // for unknown protocols const char *const aUrlPath, const char *const aHost, @@ -459,7 +459,7 @@ URL::parseFinish(const AnyP::ProtocolType protocol, } void -URL::touch() +AnyP::Uri::touch() { absolute_.clear(); authorityHttp_.clear(); @@ -467,7 +467,7 @@ URL::touch() } SBuf & -URL::authority(bool requirePort) const +AnyP::Uri::authority(bool requirePort) const { if (authorityHttp_.isEmpty()) { @@ -485,7 +485,7 @@ URL::authority(bool requirePort) const } SBuf & -URL::absolute() const +AnyP::Uri::absolute() const { if (absolute_.isEmpty()) { // TODO: most URL will be much shorter, avoid allocating this much @@ -774,7 +774,7 @@ urlCheckRequest(const HttpRequest * r) // we support OPTIONS and TRACE directed at us (with a 501 reply, for now) // we also support forwarding OPTIONS and TRACE, except for the *-URI ones if (r->method == Http::METHOD_OPTIONS || r->method == Http::METHOD_TRACE) - return (r->header.getInt64(Http::HdrType::MAX_FORWARDS) == 0 || r->url.path() != URL::Asterisk()); + return (r->header.getInt64(Http::HdrType::MAX_FORWARDS) == 0 || r->url.path() != AnyP::Uri::Asterisk()); if (r->method == Http::METHOD_PURGE) return 1; @@ -928,7 +928,7 @@ URLHostName::extract(char const *aUrl) return Host; } -URL::URL(AnyP::UriScheme const &aScheme) : +AnyP::Uri::Uri(AnyP::UriScheme const &aScheme) : scheme_(aScheme), hostIsNumeric_(false), port_(0) diff --git a/src/URL.h b/src/anyp/Uri.h similarity index 90% rename from src/URL.h rename to src/anyp/Uri.h index 97882df03f..5806438e2b 100644 --- a/src/URL.h +++ b/src/anyp/Uri.h @@ -6,8 +6,8 @@ * Please see the COPYING and CONTRIBUTORS files for details. */ -#ifndef SQUID_SRC_URL_H -#define SQUID_SRC_URL_H +#ifndef SQUID_SRC_ANYP_URI_H +#define SQUID_SRC_ANYP_URI_H #include "anyp/UriScheme.h" #include "ip/Address.h" @@ -16,22 +16,28 @@ #include +class HttpRequestMethod; + +namespace AnyP +{ + /** - * The URL class represents a Uniform Resource Location + * Represents a Uniform Resource Identifier. + * Can store both URL or URN representations. * * Governed by RFC 3986 */ -class URL +class Uri { - MEMPROXY_CLASS(URL); + MEMPROXY_CLASS(Uri); public: - URL() : hostIsNumeric_(false), port_(0) {*host_=0;} - URL(AnyP::UriScheme const &aScheme); - URL(const URL &other) { + Uri() : hostIsNumeric_(false), port_(0) {*host_=0;} + Uri(AnyP::UriScheme const &aScheme); + Uri(const Uri &other) { this->operator =(other); } - URL &operator =(const URL &o) { + Uri &operator =(const Uri &o) { scheme_ = o.scheme_; userInfo_ = o.userInfo_; memcpy(host_, o.host_, sizeof(host_)); @@ -81,7 +87,7 @@ public: /// the static '/' default URL-path static const SBuf &SlashPath(); - /// the static '*' pseudo-URL + /// the static '*' pseudo-URI static const SBuf &Asterisk(); /** @@ -119,14 +125,14 @@ private: * is to have one prototype URL with no host etc for each scheme, * another is to have an explicit scheme class, and then each URL class * could be a subclass of the scheme. Another way is one instance of - * a AnyP::UriScheme class instance for each URL scheme we support, and one URL + * a AnyP::UriScheme class instance for each URL scheme we support, and one * class for each manner of treating the scheme : a Hierarchical URL, a * non-hierarchical URL etc. \par * Deferring the decision, its a type code for now. RBC 20060507. \par - * In order to make taking any of these routes easy, scheme is private - * and immutable, only settable at construction time, + * In order to make taking any of these routes easy, scheme is private, + * only settable at construction time, or with explicit setter */ AnyP::UriScheme scheme_; @@ -141,16 +147,18 @@ private: unsigned short port_; ///< URL port // XXX: for now includes query-string. - SBuf path_; ///< URL path segment + SBuf path_; ///< URI path segment - // pre-assembled URL forms + // pre-assembled URI forms mutable SBuf authorityHttp_; ///< RFC 7230 section 5.3.3 authority, maybe without default-port mutable SBuf authorityWithPort_; ///< RFC 7230 section 5.3.3 authority with explicit port mutable SBuf absolute_; ///< RFC 7230 section 5.3.2 absolute-URI }; +} // namespace AnyP + inline std::ostream & -operator <<(std::ostream &os, const URL &url) +operator <<(std::ostream &os, const AnyP::Uri &url) { // none means explicit empty string for scheme. if (url.getScheme() != AnyP::PROTO_NONE) @@ -166,8 +174,9 @@ operator <<(std::ostream &os, const URL &url) return os; } +/* Deprecated functions for Legacy code handling URLs */ + class HttpRequest; -class HttpRequestMethod; void urlInitialize(void); char *urlCanonicalClean(const HttpRequest *); @@ -221,5 +230,5 @@ int urlCheckRequest(const HttpRequest *); char *urlHostname(const char *url); void urlExtMethodConfigure(void); -#endif /* SQUID_SRC_URL_H_H */ +#endif /* SQUID_SRC_ANYP_URI_H */ diff --git a/src/anyp/forward.h b/src/anyp/forward.h index dbf4f0cf5a..a10759da15 100644 --- a/src/anyp/forward.h +++ b/src/anyp/forward.h @@ -17,6 +17,7 @@ namespace AnyP class PortCfg; typedef RefCount PortCfgPointer; +class Uri; class UriScheme; } // namespace AnyP diff --git a/src/carp.cc b/src/carp.cc index 434c541ca2..58bfd464e3 100644 --- a/src/carp.cc +++ b/src/carp.cc @@ -16,7 +16,6 @@ #include "PeerSelectState.h" #include "SquidConfig.h" #include "Store.h" -#include "URL.h" #include diff --git a/src/client_side.cc b/src/client_side.cc index 0ff258707e..1e173cd61f 100644 --- a/src/client_side.cc +++ b/src/client_side.cc @@ -113,7 +113,6 @@ #include "Store.h" #include "TimeOrTag.h" #include "tools.h" -#include "URL.h" #if USE_AUTH #include "auth/UserRequest.h" diff --git a/src/client_side_reply.cc b/src/client_side_reply.cc index 2fbbb41932..2a0c71859e 100644 --- a/src/client_side_reply.cc +++ b/src/client_side_reply.cc @@ -37,7 +37,6 @@ #include "Store.h" #include "StrList.h" #include "tools.h" -#include "URL.h" #if USE_AUTH #include "auth/UserRequest.h" #endif diff --git a/src/client_side_request.cc b/src/client_side_request.cc index 52953f22cd..36bc046243 100644 --- a/src/client_side_request.cc +++ b/src/client_side_request.cc @@ -54,7 +54,6 @@ #include "Store.h" #include "StrList.h" #include "tools.h" -#include "URL.h" #include "wordlist.h" #if USE_AUTH #include "auth/UserRequest.h" @@ -1259,7 +1258,7 @@ ClientRequestContext::clientRedirectDone(const Helper::Reply &reply) // prevent broken helpers causing too much damage. If old URL == new URL skip the re-write. if (urlNote != NULL && strcmp(urlNote, http->uri)) { - URL tmpUrl; + AnyP::Uri tmpUrl; if (tmpUrl.parse(old_request->method, urlNote)) { HttpRequest *new_request = old_request->clone(); new_request->url = tmpUrl; diff --git a/src/clients/Client.cc b/src/clients/Client.cc index 207bd8db4c..f77a72bf4b 100644 --- a/src/clients/Client.cc +++ b/src/clients/Client.cc @@ -25,7 +25,6 @@ #include "StatCounters.h" #include "Store.h" #include "tools.h" -#include "URL.h" #if USE_ADAPTATION #include "adaptation/AccessCheck.h" diff --git a/src/clients/FtpGateway.cc b/src/clients/FtpGateway.cc index 19da1cfb14..90ab4fbf1b 100644 --- a/src/clients/FtpGateway.cc +++ b/src/clients/FtpGateway.cc @@ -37,7 +37,6 @@ #include "StatCounters.h" #include "Store.h" #include "tools.h" -#include "URL.h" #include "util.h" #include "wordlist.h" diff --git a/src/errorpage.cc b/src/errorpage.cc index 5d9d6be9da..c81e0a9c01 100644 --- a/src/errorpage.cc +++ b/src/errorpage.cc @@ -27,7 +27,6 @@ #include "SquidConfig.h" #include "Store.h" #include "tools.h" -#include "URL.h" #include "wordlist.h" #if USE_AUTH #include "auth/UserRequest.h" diff --git a/src/external_acl.cc b/src/external_acl.cc index 97613ea06f..54a6fb5e3d 100644 --- a/src/external_acl.cc +++ b/src/external_acl.cc @@ -35,7 +35,6 @@ #include "SquidTime.h" #include "Store.h" #include "tools.h" -#include "URL.h" #include "wordlist.h" #if USE_OPENSSL #include "ssl/ServerBump.h" diff --git a/src/format/Format.cc b/src/format/Format.cc index f1a8080086..619b6b89b3 100644 --- a/src/format/Format.cc +++ b/src/format/Format.cc @@ -27,7 +27,6 @@ #include "SquidTime.h" #include "Store.h" #include "tools.h" -#include "URL.h" #if USE_OPENSSL #include "ssl/ErrorDetail.h" #include "ssl/ServerBump.h" diff --git a/src/htcp.cc b/src/htcp.cc index 8c42006e72..56cbc11b93 100644 --- a/src/htcp.cc +++ b/src/htcp.cc @@ -35,7 +35,6 @@ #include "store_key_md5.h" #include "StoreClient.h" #include "tools.h" -#include "URL.h" typedef struct _Countstr Countstr; diff --git a/src/http.cc b/src/http.cc index f9760a4037..f3dcf010a8 100644 --- a/src/http.cc +++ b/src/http.cc @@ -56,7 +56,6 @@ #include "Store.h" #include "StrList.h" #include "tools.h" -#include "URL.h" #include "util.h" #if USE_AUTH diff --git a/src/icmp/net_db.cc b/src/icmp/net_db.cc index 66034b76a1..e375fc0b83 100644 --- a/src/icmp/net_db.cc +++ b/src/icmp/net_db.cc @@ -1084,7 +1084,7 @@ netdbHostData(const char *host, int *samp, int *rtt, int *hops) } void -netdbUpdatePeer(const URL &url, CachePeer * e, int irtt, int ihops) +netdbUpdatePeer(const AnyP::Uri &url, CachePeer *e, int irtt, int ihops) { #if USE_ICMP netdbEntry *n; diff --git a/src/icmp/net_db.h b/src/icmp/net_db.h index 7bd9ab856b..ac27f7bcd9 100644 --- a/src/icmp/net_db.h +++ b/src/icmp/net_db.h @@ -9,6 +9,7 @@ #ifndef ICMP_NET_DB_H #define ICMP_NET_DB_H +#include "anyp/forward.h" #include "hash.h" #include "ip/forward.h" #include "mem/forward.h" @@ -18,7 +19,6 @@ class HttpRequest; class netdbEntry; class PeerSelector; class StoreEntry; -class URL; class net_db_name: public hash_link /* must be first */ @@ -74,7 +74,7 @@ void netdbDump(StoreEntry *); void netdbFreeMemory(void); int netdbHostHops(const char *host); int netdbHostRtt(const char *host); -void netdbUpdatePeer(const URL &, CachePeer * e, int rtt, int hops); +void netdbUpdatePeer(const AnyP::Uri &, CachePeer *, int rtt, int hops); void netdbDeleteAddrNetwork(Ip::Address &addr); void netdbBinaryExchange(StoreEntry *); diff --git a/src/internal.cc b/src/internal.cc index 19fedf08f5..6ebc7a6793 100644 --- a/src/internal.cc +++ b/src/internal.cc @@ -20,7 +20,6 @@ #include "SquidTime.h" #include "Store.h" #include "tools.h" -#include "URL.h" #include "util.h" #include "wordlist.h" @@ -108,7 +107,7 @@ internalRemoteUri(const char *host, unsigned short port, const char *dir, const strlen(lc_host) - 1); /* build URI */ - URL tmp(AnyP::PROTO_HTTP); + AnyP::Uri tmp(AnyP::PROTO_HTTP); tmp.host(lc_host); if (port) tmp.port(port); diff --git a/src/main.cc b/src/main.cc index ea5a743f15..b018b64f87 100644 --- a/src/main.cc +++ b/src/main.cc @@ -80,7 +80,6 @@ #include "StoreFileSystem.h" #include "tools.h" #include "unlinkd.h" -#include "URL.h" #include "wccp.h" #include "wccp2.h" #include "WinSvc.h" diff --git a/src/neighbors.cc b/src/neighbors.cc index f76bf617b6..f55a87ee92 100644 --- a/src/neighbors.cc +++ b/src/neighbors.cc @@ -44,7 +44,6 @@ #include "Store.h" #include "store_key_md5.h" #include "tools.h" -#include "URL.h" /* count mcast group peers every 15 minutes */ #define MCAST_COUNT_RATE 900 @@ -111,7 +110,7 @@ whichPeer(const Ip::Address &from) } peer_t -neighborType(const CachePeer * p, const URL &url) +neighborType(const CachePeer * p, const AnyP::Uri &url) { const NeighborTypeDomainList *d = NULL; @@ -1405,7 +1404,7 @@ peerCountMcastPeersStart(void *data) MemObject *mem; icp_common_t *query; int reqnum; - // TODO: use class URL instead of constructing and re-parsing a string + // TODO: use class AnyP::Uri instead of constructing and re-parsing a string LOCAL_ARRAY(char, url, MAX_URL); assert(p->type == PEER_MULTICAST); p->mcast.flags.count_event_pending = false; diff --git a/src/neighbors.h b/src/neighbors.h index f2e748e201..9d98259525 100644 --- a/src/neighbors.h +++ b/src/neighbors.h @@ -11,6 +11,7 @@ #ifndef SQUID_NEIGHBORS_H_ #define SQUID_NEIGHBORS_H_ +#include "anyp/forward.h" #include "enums.h" #include "ICP.h" #include "lookup_t.h" @@ -20,7 +21,6 @@ class HttpRequest; class HttpRequestMethod; class CachePeer; class StoreEntry; -class URL; class PeerSelector; CachePeer *getFirstPeer(void); @@ -55,7 +55,7 @@ void peerNoteDigestLookup(HttpRequest * request, CachePeer * p, lookup_t lookup) void peerNoteDigestGone(CachePeer * p); int neighborUp(const CachePeer * e); const char *neighborTypeStr(const CachePeer * e); -peer_t neighborType(const CachePeer *, const URL &); +peer_t neighborType(const CachePeer *, const AnyP::Uri &); void peerConnectFailed(CachePeer *); void peerConnectSucceded(CachePeer *); void dump_peer_options(StoreEntry *, CachePeer *); diff --git a/src/peer_select.cc b/src/peer_select.cc index b49f9fd0cc..0f7c0b80c3 100644 --- a/src/peer_select.cc +++ b/src/peer_select.cc @@ -34,7 +34,6 @@ #include "SquidConfig.h" #include "SquidTime.h" #include "Store.h" -#include "URL.h" /** * A CachePeer which has been selected as a possible destination. diff --git a/src/refresh.cc b/src/refresh.cc index 0e6285fa82..5296dbec25 100644 --- a/src/refresh.cc +++ b/src/refresh.cc @@ -22,7 +22,6 @@ #include "SquidConfig.h" #include "SquidTime.h" #include "Store.h" -#include "URL.h" #include "util.h" typedef enum { diff --git a/src/servers/FtpServer.cc b/src/servers/FtpServer.cc index 0a1ee43ec6..c6ffa94fb6 100644 --- a/src/servers/FtpServer.cc +++ b/src/servers/FtpServer.cc @@ -339,7 +339,7 @@ Ftp::Server::resetLogin(const char *reason) void Ftp::Server::calcUri(const SBuf *file) { - // TODO: fill a class URL instead of string + // TODO: fill a class AnyP::Uri instead of string uri = "ftp://"; uri.append(host); if (port->ftp_track_dirs && master->workingDir.length()) { diff --git a/src/ssl/ServerBump.cc b/src/ssl/ServerBump.cc index 1c8d61a08f..d5d255398f 100644 --- a/src/ssl/ServerBump.cc +++ b/src/ssl/ServerBump.cc @@ -9,14 +9,13 @@ /* DEBUG: section 33 Client-side Routines */ #include "squid.h" - +#include "anyp/Uri.h" #include "client_side.h" #include "FwdState.h" #include "http/Stream.h" #include "ssl/ServerBump.h" #include "Store.h" #include "StoreClient.h" -#include "URL.h" CBDATA_NAMESPACED_CLASS_INIT(Ssl, ServerBump); diff --git a/src/ssl/support.cc b/src/ssl/support.cc index 8c9647d061..e2cb852641 100644 --- a/src/ssl/support.cc +++ b/src/ssl/support.cc @@ -17,6 +17,7 @@ #include "acl/FilledChecklist.h" #include "anyp/PortCfg.h" +#include "anyp/Uri.h" #include "fatal.h" #include "fd.h" #include "fde.h" @@ -31,7 +32,6 @@ #include "ssl/ErrorDetail.h" #include "ssl/gadgets.h" #include "ssl/support.h" -#include "URL.h" #include diff --git a/src/store_key_md5.cc b/src/store_key_md5.cc index b4cde67bbc..e80a788111 100644 --- a/src/store_key_md5.cc +++ b/src/store_key_md5.cc @@ -12,7 +12,6 @@ #include "HttpRequest.h" #include "md5.h" #include "store_key_md5.h" -#include "URL.h" static cache_key null_key[SQUID_MD5_DIGEST_LENGTH]; diff --git a/src/tests/Stub.list b/src/tests/Stub.list index 5cb3c3ac95..f22dd50535 100644 --- a/src/tests/Stub.list +++ b/src/tests/Stub.list @@ -41,6 +41,7 @@ STUB_SOURCE= tests/STUB.h \ tests/stub_ipc.cc \ tests/stub_ipc_Forwarder.cc \ tests/stub_ipc_TypedMsgHdr.cc \ + tests/stub_libanyp.cc \ tests/stub_libauth_acls.cc \ tests/stub_libauth.cc \ tests/stub_libcomm.cc \ @@ -81,7 +82,6 @@ STUB_SOURCE= tests/STUB.h \ tests/stub_tools.cc \ tests/stub_tunnel.cc \ tests/stub_UdsOp.cc \ - tests/stub_url.cc \ tests/stub_wccp2.cc \ tests/stub_whois.cc \ tests/stub_wordlist.cc diff --git a/src/tests/stub_url.cc b/src/tests/stub_libanyp.cc similarity index 70% rename from src/tests/stub_url.cc rename to src/tests/stub_libanyp.cc index b134352744..0a7d347da2 100644 --- a/src/tests/stub_url.cc +++ b/src/tests/stub_libanyp.cc @@ -8,28 +8,28 @@ #include "squid.h" -#define STUB_API "url.cc" +#define STUB_API "anyp/libanyp.la" #include "tests/STUB.h" -#include "URL.h" -URL::URL(AnyP::UriScheme const &) {STUB} -void URL::touch() STUB -bool URL::parse(const HttpRequestMethod&, const char *) STUB_RETVAL(true) -void URL::host(const char *) STUB +#include "anyp/Uri.h" +AnyP::Uri::Uri(AnyP::UriScheme const &) {STUB} +void AnyP::Uri::touch() STUB +bool AnyP::Uri::parse(const HttpRequestMethod&, const char *) STUB_RETVAL(true) +void AnyP::Uri::host(const char *) STUB static SBuf nil; -const SBuf &URL::path() const STUB_RETVAL(nil) -const SBuf &URL::SlashPath() +const SBuf &AnyP::Uri::path() const STUB_RETVAL(nil) +const SBuf &AnyP::Uri::SlashPath() { static SBuf slash("/"); return slash; } -const SBuf &URL::Asterisk() +const SBuf &AnyP::Uri::Asterisk() { static SBuf asterisk("*"); return asterisk; } -SBuf &URL::authority(bool) const STUB_RETVAL(nil) -SBuf &URL::absolute() const STUB_RETVAL(nil) +SBuf &AnyP::Uri::authority(bool) const STUB_RETVAL(nil) +SBuf &AnyP::Uri::absolute() const STUB_RETVAL(nil) void urlInitialize() STUB char *urlCanonicalClean(const HttpRequest *) STUB_RETVAL(nullptr) const char *urlCanonicalFakeHttps(const HttpRequest *) STUB_RETVAL(nullptr) diff --git a/src/tests/stub_libicmp.cc b/src/tests/stub_libicmp.cc index 66b1ab2e1b..87e6d00cba 100644 --- a/src/tests/stub_libicmp.cc +++ b/src/tests/stub_libicmp.cc @@ -30,7 +30,7 @@ void netdbDump(StoreEntry *) STUB void netdbFreeMemory(void) STUB int netdbHostHops(const char *host) STUB_RETVAL(-1) int netdbHostRtt(const char *host) STUB_RETVAL(-1) -void netdbUpdatePeer(const URL &, CachePeer * e, int rtt, int hops) STUB +void netdbUpdatePeer(const AnyP::Uri &, CachePeer *, int, int) STUB void netdbDeleteAddrNetwork(Ip::Address &addr) STUB void netdbBinaryExchange(StoreEntry *) STUB void netdbExchangeStart(void *) STUB diff --git a/src/tests/testURL.cc b/src/tests/testURL.cc index de6b59610f..5168dc7446 100644 --- a/src/tests/testURL.cc +++ b/src/tests/testURL.cc @@ -10,10 +10,10 @@ #include +#include "anyp/Uri.h" #include "Debug.h" -#include "testURL.h" +#include "tests/testURL.h" #include "unitTestMain.h" -#include "URL.h" #include @@ -36,11 +36,11 @@ void testURL::testConstructScheme() { AnyP::UriScheme empty_scheme; - URL protoless_url(AnyP::PROTO_NONE); + AnyP::Uri protoless_url(AnyP::PROTO_NONE); CPPUNIT_ASSERT_EQUAL(empty_scheme, protoless_url.getScheme()); AnyP::UriScheme ftp_scheme(AnyP::PROTO_FTP); - URL ftp_url(AnyP::PROTO_FTP); + AnyP::Uri ftp_url(AnyP::PROTO_FTP); CPPUNIT_ASSERT_EQUAL(ftp_scheme, ftp_url.getScheme()); } @@ -53,10 +53,10 @@ void testURL::testDefaultConstructor() { AnyP::UriScheme aScheme; - URL aUrl; + AnyP::Uri aUrl; CPPUNIT_ASSERT_EQUAL(aScheme, aUrl.getScheme()); - URL *urlPointer = new URL; + auto *urlPointer = new AnyP::Uri; CPPUNIT_ASSERT(urlPointer != NULL); delete urlPointer; } diff --git a/src/urn.cc b/src/urn.cc index 68f2acc126..8cac2a6a0b 100644 --- a/src/urn.cc +++ b/src/urn.cc @@ -24,7 +24,6 @@ #include "Store.h" #include "StoreClient.h" #include "tools.h" -#include "URL.h" #include "urn.h" #define URN_REQBUF_SZ 4096 @@ -149,7 +148,7 @@ UrnState::setUriResFromRequest(HttpRequest *r) } SBuf uri = r->url.path(); - // TODO: use class URL instead of generating a string and re-parsing + // TODO: use class AnyP::Uri instead of generating a string and re-parsing LOCAL_ARRAY(char, local_urlres, 4096); char *host = getHost(uri); snprintf(local_urlres, 4096, "http://%s/uri-res/N2L?urn:" SQUIDSBUFPH, host, SQUIDSBUFPRINT(uri)); -- 2.47.2