------------------------------------------------------------ revno: 13260 revision-id: squid3@treenet.co.nz-20140207134520-oigqzdup6mbxm7eb parent: squid3@treenet.co.nz-20140206121608-h75n503a5pyxxy1x committer: Amos Jeffries branch nick: trunk timestamp: Fri 2014-02-07 06:45:20 -0700 message: SourceLayout: shuffle URLScheme to AnyP::UriScheme This class holds a generic protocol agnostic Scheme representation. * rename const_str() member to c_str() since it produces a const C-string (char*) representation. * Remove some unecessary dependencies. * Cleanup the coding style to match guidelines. ------------------------------------------------------------ # Bazaar merge directive format 2 (Bazaar 0.90) # revision_id: squid3@treenet.co.nz-20140207134520-oigqzdup6mbxm7eb # target_branch: http://bzr.squid-cache.org/bzr/squid3/trunk/ # testament_sha1: b89c3219ef58c50a15b4f1eea42b154cfcec07af # timestamp: 2014-02-07 13:50:23 +0000 # source_branch: http://bzr.squid-cache.org/bzr/squid3/trunk/ # base_revision_id: squid3@treenet.co.nz-20140206121608-\ # h75n503a5pyxxy1x # # Begin patch === modified file 'src/Makefile.am' --- src/Makefile.am 2014-01-12 17:51:12 +0000 +++ src/Makefile.am 2014-02-07 13:45:20 +0000 @@ -555,8 +555,6 @@ $(UNLINKDSOURCE) \ url.cc \ URL.h \ - URLScheme.cc \ - URLScheme.h \ urn.h \ urn.cc \ wccp.h \ @@ -1193,7 +1191,6 @@ tests/testMain.cc \ tests/stub_time.cc \ url.cc \ - URLScheme.cc \ wordlist.h \ wordlist.cc nodist_tests_testHttpReply_SOURCES=\ @@ -1327,8 +1324,6 @@ tests/stub_time.cc \ url.cc \ URL.h \ - URLScheme.cc \ - URLScheme.h \ Mem.h \ tests/stub_mem.cc \ MemBuf.cc \ @@ -1574,7 +1569,6 @@ MemStore.cc \ $(UNLINKDSOURCE) \ url.cc \ - URLScheme.cc \ urn.h \ urn.cc \ wccp2.h \ @@ -1762,7 +1756,6 @@ tests/stub_time.cc \ $(UNLINKDSOURCE) \ url.cc \ - URLScheme.cc \ $(WIN32_SOURCE) \ wordlist.h \ wordlist.cc \ @@ -2007,7 +2000,6 @@ MemStore.cc \ $(UNLINKDSOURCE) \ url.cc \ - URLScheme.cc \ urn.h \ urn.cc \ wccp2.h \ @@ -2255,7 +2247,6 @@ MemStore.cc \ $(UNLINKDSOURCE) \ url.cc \ - URLScheme.cc \ urn.h \ urn.cc \ wccp2.h \ @@ -2496,7 +2487,6 @@ tests/stub_tunnel.cc \ $(UNLINKDSOURCE) \ url.cc \ - URLScheme.cc \ urn.h \ urn.cc \ wccp2.h \ @@ -2786,7 +2776,6 @@ tests/stub_SwapDir.cc \ MemStore.cc \ url.cc \ - URLScheme.cc \ urn.h \ urn.cc \ wccp2.h \ @@ -2973,7 +2962,6 @@ tests/TestSwapDir.h \ tests/stub_time.cc \ url.cc \ - URLScheme.cc \ wordlist.h \ wordlist.cc @@ -3202,7 +3190,6 @@ tests/testStoreSupport.cc \ tests/testStoreSupport.h \ time.cc \ - URLScheme.cc \ wordlist.h \ wordlist.cc \ $(DISKIO_SOURCE) @@ -3385,7 +3372,6 @@ tests/stub_tools.cc \ time.cc \ url.cc \ - URLScheme.cc \ wordlist.h \ wordlist.cc \ $(DELAY_POOL_SOURCE) \ @@ -3614,8 +3600,8 @@ tests/stub_store_stats.cc \ tests/testURL.cc \ tests/testURL.h \ - tests/testURLScheme.cc \ - tests/testURLScheme.h \ + tests/testUriScheme.cc \ + tests/testUriScheme.h \ tests/testMain.cc \ tests/stub_time.cc \ tests/stub_EventLoop.cc \ @@ -3623,7 +3609,6 @@ tools.cc \ tests/stub_tunnel.cc \ url.cc \ - URLScheme.cc \ urn.h \ urn.cc \ wccp2.h \ === modified file 'src/URL.h' --- src/URL.h 2012-09-21 14:57:30 +0000 +++ src/URL.h 2014-02-07 13:45:20 +0000 @@ -31,9 +31,8 @@ #ifndef SQUID_SRC_URL_H #define SQUID_SRC_URL_H -#include "anyp/ProtocolType.h" +#include "anyp/UriScheme.h" #include "MemPool.h" -#include "URLScheme.h" /** \ingroup POD @@ -42,13 +41,11 @@ */ class URL { - public: - MEMPROXY_CLASS(URL); - URL(); - URL(URLScheme const &); - URLScheme const & getScheme() const {return scheme; } + URL() : scheme_() {} + URL(AnyP::UriScheme const &aScheme) : scheme_(aScheme) {} + AnyP::UriScheme const & getScheme() const {return scheme_;} private: /** @@ -62,7 +59,7 @@ * 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 URLScheme class instance for each URLScheme we support, and one URL + * a AnyP::UriScheme class instance for each URL scheme we support, and one URL * class for each manner of treating the scheme : a Hierarchical URL, a * non-hierarchical URL etc. \par @@ -71,7 +68,7 @@ * In order to make taking any of these routes easy, scheme is private * and immutable, only settable at construction time, */ - URLScheme const scheme; + AnyP::UriScheme const scheme_; }; MEMPROXY_CLASS_INLINE(URL); === modified file 'src/acl/ProtocolData.cc' --- src/acl/ProtocolData.cc 2014-01-11 01:35:50 +0000 +++ src/acl/ProtocolData.cc 2014-02-07 13:45:20 +0000 @@ -37,7 +37,6 @@ #include "acl/ProtocolData.h" #include "cache_cf.h" #include "Debug.h" -#include "URLScheme.h" #include "wordlist.h" ACLProtocolData::ACLProtocolData() : values (NULL) === modified file 'src/anyp/Makefile.am' --- src/anyp/Makefile.am 2013-06-13 11:08:58 +0000 +++ src/anyp/Makefile.am 2014-02-07 13:45:20 +0000 @@ -10,7 +10,9 @@ ProtocolType.cc \ ProtocolType.h \ ProtocolVersion.h \ - TrafficMode.h + TrafficMode.h \ + UriScheme.cc \ + UriScheme.h ProtocolType.cc: ProtocolType.h $(top_srcdir)/src/mk-string-arrays.awk ($(AWK) -f $(top_srcdir)/src/mk-string-arrays.awk <$(srcdir)/ProtocolType.h | sed -e 's%PROTO_%%' >$@) || ($(RM) -f $@ && exit 1) === renamed file 'src/URLScheme.cc' => 'src/anyp/UriScheme.cc' --- src/URLScheme.cc 2012-09-01 14:38:36 +0000 +++ src/anyp/UriScheme.cc 2014-02-07 13:45:20 +0000 @@ -1,42 +1,12 @@ - /* * DEBUG: section 23 URL Scheme parsing - * AUTHOR: Robert Collins - * - * SQUID Web Proxy Cache http://www.squid-cache.org/ - * ---------------------------------------------------------- - * - * Squid is the result of efforts by numerous individuals from - * the Internet community; see the CONTRIBUTORS file for full - * details. Many organizations have provided support for Squid's - * development; see the SPONSORS file for full details. Squid is - * Copyrighted (C) 2001 by the Regents of the University of - * California; see the COPYRIGHT file for full details. Squid - * incorporates software developed and/or copyrighted by other - * sources; see the CREDITS file for full details. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. - * + * AUTHOR: Robert Collins, Amos Jeffries */ - #include "squid.h" -#include "URLScheme.h" -#include "wordlist.h" +#include "anyp/UriScheme.h" char const * -URLScheme::const_str() const +AnyP::UriScheme::c_str() const { if (theScheme_ == AnyP::PROTO_UNKNOWN) return "(unknown)"; === renamed file 'src/URLScheme.h' => 'src/anyp/UriScheme.h' --- src/URLScheme.h 2012-09-01 14:38:36 +0000 +++ src/anyp/UriScheme.h 2014-02-07 13:45:20 +0000 @@ -1,74 +1,49 @@ - -/* - * - * SQUID Web Proxy Cache http://www.squid-cache.org/ - * ---------------------------------------------------------- - * - * Squid is the result of efforts by numerous individuals from - * the Internet community; see the CONTRIBUTORS file for full - * details. Many organizations have provided support for Squid's - * development; see the SPONSORS file for full details. Squid is - * Copyrighted (C) 2001 by the Regents of the University of - * California; see the COPYRIGHT file for full details. Squid - * incorporates software developed and/or copyrighted by other - * sources; see the CREDITS file for full details. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. - * - */ - -#ifndef SQUID_URLSCHEME_H -#define SQUID_URLSCHEME_H +#ifndef SQUID_ANYP_URISCHEME_H +#define SQUID_ANYP_URISCHEME_H #include "anyp/ProtocolType.h" #if HAVE_IOSFWD #include #endif -/** This class represents a URL Scheme such as HTTPS, HTTP, WAIS etc. +namespace AnyP +{ + +/** This class represents a URI Scheme such as http:// https://, wais://, urn: etc. * It does not represent the PROTOCOL that such schemes refer to. */ -class URLScheme +class UriScheme { - public: - URLScheme() : theScheme_(AnyP::PROTO_NONE) {} - URLScheme(AnyP::ProtocolType const aScheme) : theScheme_(aScheme) {} - ~URLScheme() {} + UriScheme() : theScheme_(AnyP::PROTO_NONE) {} + UriScheme(AnyP::ProtocolType const aScheme) : theScheme_(aScheme) {} + ~UriScheme() {} operator AnyP::ProtocolType() const { return theScheme_; } bool operator != (AnyP::ProtocolType const & aProtocol) const { return theScheme_ != aProtocol; } /** Get a char string representation of the scheme. + * Does not include the ':' or '://" terminators. + * * An upper bound length of BUFSIZ bytes converted. Remainder will be truncated. * The result of this call will remain usable only until any subsequest call * and must be copied if persistence is needed. */ - char const *const_str() const; + char const *c_str() const; private: /// This is a typecode pointer into the enum/registry of protocols handled. AnyP::ProtocolType theScheme_; }; +} // namespace AnyP + inline std::ostream & -operator << (std::ostream &os, URLScheme const &scheme) +operator << (std::ostream &os, AnyP::UriScheme const &scheme) { - os << scheme.const_str(); + os << scheme.c_str(); return os; } -#endif /* SQUID_URLSCHEME_H */ +#endif /* SQUID_ANYP_URISCHEME_H */ === modified file 'src/anyp/forward.h' --- src/anyp/forward.h 2013-06-13 11:08:58 +0000 +++ src/anyp/forward.h 2014-02-07 13:45:20 +0000 @@ -9,6 +9,8 @@ class PortCfg; typedef CbcPointer PortCfgPointer; +class UriScheme; + } // namespace AnyP #endif /* _SQUID_SRC_ANYP_FORWARD_H */ === modified file 'src/cache_cf.cc' --- src/cache_cf.cc 2014-01-27 03:06:15 +0000 +++ src/cache_cf.cc 2014-02-07 13:45:20 +0000 @@ -40,6 +40,7 @@ #include "acl/MethodData.h" #include "acl/Tree.h" #include "anyp/PortCfg.h" +#include "anyp/UriScheme.h" #include "AuthReg.h" #include "base/RunnersRegistry.h" #include "cache_cf.h" @@ -78,7 +79,6 @@ #include "StoreFileSystem.h" #include "SwapDir.h" #include "tools.h" -#include "URLScheme.h" #include "wordlist.h" /* wccp2 has its own conditional definitions */ #include "wccp2.h" @@ -3513,7 +3513,7 @@ s->name = xstrdup(token); s->connection_auth_disabled = false; - const char *portType = URLScheme(s->transport.protocol).const_str(); + const char *portType = AnyP::UriScheme(s->transport.protocol).c_str(); if (*token == '[') { /* [ipv6]:port */ @@ -3832,7 +3832,7 @@ // clone the port options from *s to *(s->next) s->next = cbdataReference(s->clone()); s->next->s.setIPv4(); - debugs(3, 3, URLScheme(s->transport.protocol) << "_port: clone wildcard address for split-stack: " << s->s << " and " << s->next->s); + debugs(3, 3, AnyP::UriScheme(s->transport.protocol).c_str() << "_port: clone wildcard address for split-stack: " << s->s << " and " << s->next->s); } while (*head) @@ -3873,7 +3873,7 @@ // TODO: compare against prefix of 'n' instead of assuming http_port if (s->transport.protocol != AnyP::PROTO_HTTP) - storeAppendPrintf(e, " protocol=%s", URLScheme(s->transport.protocol).const_str()); + storeAppendPrintf(e, " protocol=%s", AnyP::UriScheme(s->transport.protocol).c_str()); if (s->allow_direct) storeAppendPrintf(e, " allow-direct"); === modified file 'src/carp.cc' --- src/carp.cc 2012-09-04 15:15:51 +0000 +++ src/carp.cc 2014-02-07 13:45:20 +0000 @@ -40,7 +40,6 @@ #include "SquidConfig.h" #include "Store.h" #include "URL.h" -#include "URLScheme.h" #if HAVE_MATH_H #include @@ -195,8 +194,8 @@ // corner cases should use the canonical URL if (tp->options.carp_key.scheme) { // temporary, until bug 1961 URL handling is fixed. - const URLScheme sch = request->protocol; - key.append(sch.const_str()); + const AnyP::UriScheme sch(request->protocol); + key.append(sch.c_str()); if (key.size()) //if the scheme is not empty key.append("://"); } === modified file 'src/client_side.cc' --- src/client_side.cc 2014-02-06 09:30:48 +0000 +++ src/client_side.cc 2014-02-07 13:45:20 +0000 @@ -2120,7 +2120,7 @@ strlen(host); http->uri = (char *)xcalloc(url_sz, 1); const char *protocol = switchedToHttps ? - "https" : URLScheme(conn->port->transport.protocol).const_str(); + "https" : AnyP::UriScheme(conn->port->transport.protocol).c_str(); snprintf(http->uri, url_sz, "%s://%s%s", protocol, host, url); debugs(33, 5, "ACCEL VHOST REWRITE: '" << http->uri << "'"); } else if (conn->port->defaultsite /* && !vhost */) { @@ -2134,7 +2134,7 @@ snprintf(vportStr, sizeof(vportStr),":%d",vport); } snprintf(http->uri, url_sz, "%s://%s%s%s", - URLScheme(conn->port->transport.protocol).const_str(), conn->port->defaultsite, vportStr, url); + AnyP::UriScheme(conn->port->transport.protocol).c_str(), conn->port->defaultsite, vportStr, url); debugs(33, 5, "ACCEL DEFAULTSITE REWRITE: '" << http->uri <<"'"); } else if (vport > 0 /* && (!vhost || no Host:) */) { debugs(33, 5, "ACCEL VPORT REWRITE: http_port IP + vport=" << vport); @@ -2143,7 +2143,7 @@ http->uri = (char *)xcalloc(url_sz, 1); http->getConn()->clientConnection->local.toHostStr(ipbuf,MAX_IPSTRLEN); snprintf(http->uri, url_sz, "%s://%s:%d%s", - URLScheme(conn->port->transport.protocol).const_str(), + AnyP::UriScheme(conn->port->transport.protocol).c_str(), ipbuf, vport, url); debugs(33, 5, "ACCEL VPORT REWRITE: '" << http->uri << "'"); } @@ -2164,7 +2164,7 @@ int url_sz = strlen(url) + 32 + Config.appendDomainLen + strlen(host); http->uri = (char *)xcalloc(url_sz, 1); - snprintf(http->uri, url_sz, "%s://%s%s", URLScheme(conn->port->transport.protocol).const_str(), host, url); + snprintf(http->uri, url_sz, "%s://%s%s", AnyP::UriScheme(conn->port->transport.protocol).c_str(), host, url); debugs(33, 5, "TRANSPARENT HOST REWRITE: '" << http->uri <<"'"); } else { /* Put the local socket IP address as the hostname. */ @@ -2172,7 +2172,7 @@ http->uri = (char *)xcalloc(url_sz, 1); http->getConn()->clientConnection->local.toHostStr(ipbuf,MAX_IPSTRLEN); snprintf(http->uri, url_sz, "%s://%s:%d%s", - URLScheme(http->getConn()->port->transport.protocol).const_str(), + AnyP::UriScheme(http->getConn()->port->transport.protocol).c_str(), ipbuf, http->getConn()->clientConnection->local.port(), url); debugs(33, 5, "TRANSPARENT REWRITE: '" << http->uri << "'"); } @@ -4071,7 +4071,7 @@ #if USE_SSL if (s->flags.tunnelSslBumping && !Config.accessList.ssl_bump) { - debugs(33, DBG_IMPORTANT, "WARNING: No ssl_bump configured. Disabling ssl-bump on " << URLScheme(s->transport.protocol) << "_port " << s->s); + debugs(33, DBG_IMPORTANT, "WARNING: No ssl_bump configured. Disabling ssl-bump on " << AnyP::UriScheme(s->transport.protocol) << "_port " << s->s); s->flags.tunnelSslBumping = false; } @@ -4128,7 +4128,7 @@ // TODO: merge with similar code in clientHttpConnectionsOpen() if (s->flags.tunnelSslBumping && !Config.accessList.ssl_bump) { - debugs(33, DBG_IMPORTANT, "WARNING: No ssl_bump configured. Disabling ssl-bump on " << URLScheme(s->transport.protocol) << "_port " << s->s); + debugs(33, DBG_IMPORTANT, "WARNING: No ssl_bump configured. Disabling ssl-bump on " << AnyP::UriScheme(s->transport.protocol) << "_port " << s->s); s->flags.tunnelSslBumping = false; } === modified file 'src/errorpage.cc' --- src/errorpage.cc 2014-01-20 01:20:40 +0000 +++ src/errorpage.cc 2014-02-07 13:45:20 +0000 @@ -49,8 +49,6 @@ #include "Store.h" #include "tools.h" #include "URL.h" -#include "URL.h" -#include "URLScheme.h" #include "wordlist.h" #if USE_AUTH #include "auth/UserRequest.h" === modified file 'src/external_acl.cc' --- src/external_acl.cc 2013-11-29 04:41:07 +0000 +++ src/external_acl.cc 2014-02-07 13:45:20 +0000 @@ -62,7 +62,6 @@ #include "Store.h" #include "tools.h" #include "URL.h" -#include "URLScheme.h" #include "wordlist.h" #if USE_SSL #include "ssl/support.h" === modified file 'src/ftp.cc' --- src/ftp.cc 2014-01-19 05:39:55 +0000 +++ src/ftp.cc 2014-02-07 13:45:20 +0000 @@ -60,7 +60,6 @@ #include "Store.h" #include "tools.h" #include "URL.h" -#include "URLScheme.h" #include "wordlist.h" #if USE_DELAY_POOLS === modified file 'src/tests/testURL.cc' --- src/tests/testURL.cc 2013-10-25 00:13:46 +0000 +++ src/tests/testURL.cc 2014-02-07 13:45:20 +0000 @@ -22,17 +22,17 @@ } /* - * we can construct a URL with a URLScheme. + * we can construct a URL with a AnyP::UriScheme. * This creates a URL for that scheme. */ void testURL::testConstructScheme() { - URLScheme empty_scheme; + AnyP::UriScheme empty_scheme; URL protoless_url(AnyP::PROTO_NONE); CPPUNIT_ASSERT_EQUAL(empty_scheme, protoless_url.getScheme()); - URLScheme ftp_scheme(AnyP::PROTO_FTP); + AnyP::UriScheme ftp_scheme(AnyP::PROTO_FTP); URL ftp_url(AnyP::PROTO_FTP); CPPUNIT_ASSERT_EQUAL(ftp_scheme, ftp_url.getScheme()); } @@ -45,7 +45,7 @@ void testURL::testDefaultConstructor() { - URLScheme aScheme; + AnyP::UriScheme aScheme; URL aUrl; CPPUNIT_ASSERT_EQUAL(aScheme, aUrl.getScheme()); === renamed file 'src/tests/testURLScheme.cc' => 'src/tests/testUriScheme.cc' --- src/tests/testURLScheme.cc 2012-08-28 13:00:30 +0000 +++ src/tests/testUriScheme.cc 2014-02-07 13:45:20 +0000 @@ -4,16 +4,16 @@ #include +#include "anyp/UriScheme.h" #include "Mem.h" #include "SquidString.h" -#include "testURLScheme.h" -#include "URLScheme.h" +#include "tests/testUriScheme.h" #if HAVE_SSTREAM #include #endif -CPPUNIT_TEST_SUITE_REGISTRATION( testURLScheme ); +CPPUNIT_TEST_SUITE_REGISTRATION( testUriScheme ); #if 0 /* @@ -47,58 +47,58 @@ #endif /* - * we should be able to assign a protocol_t to a URLScheme for ease + * we should be able to assign a protocol_t to a AnyP::UriScheme for ease * of code conversion */ void -testURLScheme::testAssignFromprotocol_t() +testUriScheme::testAssignFromprotocol_t() { - URLScheme empty_scheme; - URLScheme scheme; + AnyP::UriScheme empty_scheme; + AnyP::UriScheme scheme; scheme = AnyP::PROTO_NONE; CPPUNIT_ASSERT_EQUAL(empty_scheme, scheme); - URLScheme https_scheme(AnyP::PROTO_HTTPS); + AnyP::UriScheme https_scheme(AnyP::PROTO_HTTPS); scheme = AnyP::PROTO_HTTPS; CPPUNIT_ASSERT_EQUAL(https_scheme, scheme); } /* - * We should be able to get a protocol_t from a URLScheme for ease + * We should be able to get a protocol_t from a AnyP::UriScheme for ease * of migration */ void -testURLScheme::testCastToprotocol_t() +testUriScheme::testCastToprotocol_t() { /* explicit cast */ - AnyP::ProtocolType protocol = static_cast(URLScheme()); + AnyP::ProtocolType protocol = static_cast(AnyP::UriScheme()); CPPUNIT_ASSERT_EQUAL(AnyP::PROTO_NONE, protocol); /* and implicit */ - protocol = URLScheme(AnyP::PROTO_HTTP); + protocol = AnyP::UriScheme(AnyP::PROTO_HTTP); CPPUNIT_ASSERT_EQUAL(AnyP::PROTO_HTTP, protocol); } /* - * a default constructed URLScheme is == AnyP::PROTO_NONE + * a default constructed AnyP::UriScheme is == AnyP::PROTO_NONE */ void -testURLScheme::testDefaultConstructor() +testUriScheme::testDefaultConstructor() { - URLScheme lhs; - URLScheme rhs(AnyP::PROTO_NONE); + AnyP::UriScheme lhs; + AnyP::UriScheme rhs(AnyP::PROTO_NONE); CPPUNIT_ASSERT_EQUAL(lhs, rhs); } /* - * we should be able to construct a URLScheme from the old 'protocol_t' enum. + * we should be able to construct a AnyP::UriScheme from the old 'protocol_t' enum. */ void -testURLScheme::testConstructprotocol_t() +testUriScheme::testConstructprotocol_t() { - URLScheme lhs_none(AnyP::PROTO_NONE), rhs_none(AnyP::PROTO_NONE); + AnyP::UriScheme lhs_none(AnyP::PROTO_NONE), rhs_none(AnyP::PROTO_NONE); CPPUNIT_ASSERT_EQUAL(lhs_none, rhs_none); - URLScheme lhs_cacheobj(AnyP::PROTO_CACHE_OBJECT), rhs_cacheobj(AnyP::PROTO_CACHE_OBJECT); + AnyP::UriScheme lhs_cacheobj(AnyP::PROTO_CACHE_OBJECT), rhs_cacheobj(AnyP::PROTO_CACHE_OBJECT); CPPUNIT_ASSERT_EQUAL(lhs_cacheobj, rhs_cacheobj); CPPUNIT_ASSERT(lhs_none != rhs_cacheobj); } @@ -107,47 +107,47 @@ * we should be able to get a char const * version of the method. */ void -testURLScheme::testConst_str() +testUriScheme::testC_str() { String lhs("wais"); - URLScheme wais(AnyP::PROTO_WAIS); - String rhs(wais.const_str()); + AnyP::UriScheme wais(AnyP::PROTO_WAIS); + String rhs(wais.c_str()); CPPUNIT_ASSERT_EQUAL(lhs, rhs); } /* - * a URLScheme replaces protocol_t, so we should be able to test for equality on + * a AnyP::UriScheme replaces protocol_t, so we should be able to test for equality on * either the left or right hand side seamlessly. */ void -testURLScheme::testEqualprotocol_t() +testUriScheme::testEqualprotocol_t() { - CPPUNIT_ASSERT(URLScheme() == AnyP::PROTO_NONE); - CPPUNIT_ASSERT(not (URLScheme(AnyP::PROTO_WAIS) == AnyP::PROTO_HTTP)); - CPPUNIT_ASSERT(AnyP::PROTO_HTTP == URLScheme(AnyP::PROTO_HTTP)); - CPPUNIT_ASSERT(not (AnyP::PROTO_CACHE_OBJECT == URLScheme(AnyP::PROTO_HTTP))); + CPPUNIT_ASSERT(AnyP::UriScheme() == AnyP::PROTO_NONE); + CPPUNIT_ASSERT(not (AnyP::UriScheme(AnyP::PROTO_WAIS) == AnyP::PROTO_HTTP)); + CPPUNIT_ASSERT(AnyP::PROTO_HTTP == AnyP::UriScheme(AnyP::PROTO_HTTP)); + CPPUNIT_ASSERT(not (AnyP::PROTO_CACHE_OBJECT == AnyP::UriScheme(AnyP::PROTO_HTTP))); } /* - * a URLScheme should testable for inequality with a protocol_t. + * a AnyP::UriScheme should testable for inequality with a protocol_t. */ void -testURLScheme::testNotEqualprotocol_t() +testUriScheme::testNotEqualprotocol_t() { - CPPUNIT_ASSERT(URLScheme(AnyP::PROTO_NONE) != AnyP::PROTO_HTTP); - CPPUNIT_ASSERT(not (URLScheme(AnyP::PROTO_HTTP) != AnyP::PROTO_HTTP)); - CPPUNIT_ASSERT(AnyP::PROTO_NONE != URLScheme(AnyP::PROTO_HTTP)); - CPPUNIT_ASSERT(not (AnyP::PROTO_WAIS != URLScheme(AnyP::PROTO_WAIS))); + CPPUNIT_ASSERT(AnyP::UriScheme(AnyP::PROTO_NONE) != AnyP::PROTO_HTTP); + CPPUNIT_ASSERT(not (AnyP::UriScheme(AnyP::PROTO_HTTP) != AnyP::PROTO_HTTP)); + CPPUNIT_ASSERT(AnyP::PROTO_NONE != AnyP::UriScheme(AnyP::PROTO_HTTP)); + CPPUNIT_ASSERT(not (AnyP::PROTO_WAIS != AnyP::UriScheme(AnyP::PROTO_WAIS))); } /* * we should be able to send it to a stream and get the normalised version */ void -testURLScheme::testStream() +testUriScheme::testStream() { std::ostringstream buffer; - buffer << URLScheme(AnyP::PROTO_HTTP); + buffer << AnyP::UriScheme(AnyP::PROTO_HTTP); String http_str("http"); String from_buf(buffer.str().c_str()); CPPUNIT_ASSERT_EQUAL(http_str, from_buf); === renamed file 'src/tests/testURLScheme.h' => 'src/tests/testUriScheme.h' --- src/tests/testURLScheme.h 2006-05-09 05:38:33 +0000 +++ src/tests/testUriScheme.h 2014-02-07 13:45:20 +0000 @@ -1,16 +1,16 @@ -#ifndef SQUID_SRC_TEST_URL_SCHEME_H -#define SQUID_SRC_TEST_URL_SCHEME_H +#ifndef SQUID_SRC_TESTS_TESTURISCHEME_H +#define SQUID_SRC_TESTS_TESTURISCHEME_H #include /* - * test URLScheme + * test UriScheme */ -class testURLScheme : public CPPUNIT_NS::TestFixture +class testUriScheme : public CPPUNIT_NS::TestFixture { - CPPUNIT_TEST_SUITE( testURLScheme ); + CPPUNIT_TEST_SUITE( testUriScheme ); CPPUNIT_TEST( testAssignFromprotocol_t ); CPPUNIT_TEST( testCastToprotocol_t ); CPPUNIT_TEST( testConstructprotocol_t ); @@ -23,7 +23,7 @@ CPPUNIT_TEST( testDefaultConstructor ); CPPUNIT_TEST( testEqualprotocol_t ); CPPUNIT_TEST( testNotEqualprotocol_t ); - CPPUNIT_TEST( testConst_str ); + CPPUNIT_TEST( testC_str ); CPPUNIT_TEST( testStream ); CPPUNIT_TEST_SUITE_END(); @@ -39,7 +39,7 @@ void testConstructCharStartEnd(); #endif - void testConst_str(); + void testC_str(); void testDefaultConstructor(); void testEqualprotocol_t(); void testNotEqualprotocol_t(); === modified file 'src/url.cc' --- src/url.cc 2012-12-27 17:58:29 +0000 +++ src/url.cc 2014-02-07 13:45:20 +0000 @@ -38,7 +38,6 @@ #include "SquidConfig.h" #include "SquidString.h" #include "URL.h" -#include "URLScheme.h" static HttpRequest *urlParseFinish(const HttpRequestMethod& method, const AnyP::ProtocolType protocol, @@ -515,9 +514,9 @@ if (request->port != urlDefaultPort(request->protocol)) snprintf(portbuf, 32, ":%d", request->port); - const URLScheme sch = request->protocol; // temporary, until bug 1961 URL handling is fixed. + const AnyP::UriScheme sch = request->protocol; // temporary, until bug 1961 URL handling is fixed. snprintf(urlbuf, MAX_URL, "%s://%s%s%s%s" SQUIDSTRINGPH, - sch.const_str(), + sch.c_str(), request->login, *request->login ? "@" : null_string, request->GetHost(), @@ -562,9 +561,9 @@ strcat(loginbuf, "@"); } - const URLScheme sch = request->protocol; // temporary, until bug 1961 URL handling is fixed. + const AnyP::UriScheme sch = request->protocol; // temporary, until bug 1961 URL handling is fixed. snprintf(buf, MAX_URL, "%s://%s%s%s" SQUIDSTRINGPH, - sch.const_str(), + sch.c_str(), loginbuf, request->GetHost(), portbuf, @@ -662,10 +661,10 @@ size_t urllen; - const URLScheme sch = req->protocol; // temporary, until bug 1961 URL handling is fixed. + const AnyP::UriScheme sch = req->protocol; // temporary, until bug 1961 URL handling is fixed. if (req->port != urlDefaultPort(req->protocol)) { urllen = snprintf(urlbuf, MAX_URL, "%s://%s%s%s:%d", - sch.const_str(), + sch.c_str(), req->login, *req->login ? "@" : null_string, req->GetHost(), @@ -673,7 +672,7 @@ ); } else { urllen = snprintf(urlbuf, MAX_URL, "%s://%s%s%s", - sch.const_str(), + sch.c_str(), req->login, *req->login ? "@" : null_string, req->GetHost() @@ -980,9 +979,3 @@ return Host; } - -URL::URL() : scheme() -{} - -URL::URL(URLScheme const &aScheme): scheme(aScheme) -{}