]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
SourceLayout: shuffle URLScheme to AnyP::UriScheme
authorAmos Jeffries <squid3@treenet.co.nz>
Fri, 7 Feb 2014 13:45:20 +0000 (06:45 -0700)
committerAmos Jeffries <squid3@treenet.co.nz>
Fri, 7 Feb 2014 13:45:20 +0000 (06:45 -0700)
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.

19 files changed:
src/Makefile.am
src/URL.h
src/URLScheme.cc [deleted file]
src/URLScheme.h [deleted file]
src/acl/ProtocolData.cc
src/anyp/Makefile.am
src/anyp/UriScheme.cc [new file with mode: 0644]
src/anyp/UriScheme.h [new file with mode: 0644]
src/anyp/forward.h
src/cache_cf.cc
src/carp.cc
src/client_side.cc
src/errorpage.cc
src/external_acl.cc
src/ftp.cc
src/tests/testURL.cc
src/tests/testUriScheme.cc [moved from src/tests/testURLScheme.cc with 52% similarity]
src/tests/testUriScheme.h [moved from src/tests/testURLScheme.h with 77% similarity]
src/url.cc

index 396e47c57a283be4e2edd1f625c571ef589c9bcc..400f3153d52f6e9771343a0dc29d7a56e6905aee 100644 (file)
@@ -555,8 +555,6 @@ squid_SOURCES = \
        $(UNLINKDSOURCE) \
        url.cc \
        URL.h \
-       URLScheme.cc \
-       URLScheme.h \
        urn.h \
        urn.cc \
        wccp.h \
@@ -1193,7 +1191,6 @@ tests_testHttpReply_SOURCES=\
        tests/testMain.cc \
        tests/stub_time.cc \
        url.cc \
-       URLScheme.cc \
        wordlist.h \
        wordlist.cc
 nodist_tests_testHttpReply_SOURCES=\
@@ -1327,8 +1324,6 @@ tests_testACLMaxUserIP_SOURCES= \
        tests/stub_time.cc \
        url.cc \
        URL.h \
-       URLScheme.cc \
-       URLScheme.h \
        Mem.h \
        tests/stub_mem.cc \
        MemBuf.cc \
@@ -1574,7 +1569,6 @@ tests_testCacheManager_SOURCES = \
        MemStore.cc \
        $(UNLINKDSOURCE) \
        url.cc \
-       URLScheme.cc \
        urn.h \
        urn.cc \
        wccp2.h \
@@ -1762,7 +1756,6 @@ tests_testDiskIO_SOURCES = \
        tests/stub_time.cc \
        $(UNLINKDSOURCE) \
        url.cc \
-       URLScheme.cc \
        $(WIN32_SOURCE) \
        wordlist.h \
        wordlist.cc \
@@ -2007,7 +2000,6 @@ tests_testEvent_SOURCES = \
        MemStore.cc \
        $(UNLINKDSOURCE) \
        url.cc \
-       URLScheme.cc \
        urn.h \
        urn.cc \
        wccp2.h \
@@ -2255,7 +2247,6 @@ tests_testEventLoop_SOURCES = \
        MemStore.cc \
        $(UNLINKDSOURCE) \
        url.cc \
-       URLScheme.cc \
        urn.h \
        urn.cc \
        wccp2.h \
@@ -2496,7 +2487,6 @@ tests_test_http_range_SOURCES = \
        tests/stub_tunnel.cc \
        $(UNLINKDSOURCE) \
        url.cc \
-       URLScheme.cc \
        urn.h \
        urn.cc \
        wccp2.h \
@@ -2786,7 +2776,6 @@ tests_testHttpRequest_SOURCES = \
        tests/stub_SwapDir.cc \
        MemStore.cc \
        url.cc \
-       URLScheme.cc \
        urn.h \
        urn.cc \
        wccp2.h \
@@ -2973,7 +2962,6 @@ tests_testStore_SOURCES= \
        tests/TestSwapDir.h \
        tests/stub_time.cc \
        url.cc \
-       URLScheme.cc \
        wordlist.h \
        wordlist.cc
 
@@ -3202,7 +3190,6 @@ tests_testUfs_SOURCES = \
        tests/testStoreSupport.cc \
        tests/testStoreSupport.h \
        time.cc \
-       URLScheme.cc \
        wordlist.h \
        wordlist.cc \
        $(DISKIO_SOURCE)
@@ -3385,7 +3372,6 @@ tests_testRock_SOURCES = \
        tests/stub_tools.cc \
        time.cc \
        url.cc \
-       URLScheme.cc \
        wordlist.h \
        wordlist.cc \
        $(DELAY_POOL_SOURCE) \
@@ -3614,8 +3600,8 @@ tests_testURL_SOURCES = \
        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 @@ tests_testURL_SOURCES = \
        tools.cc \
        tests/stub_tunnel.cc \
        url.cc \
-       URLScheme.cc \
        urn.h \
        urn.cc \
        wccp2.h \
index de33fab249f80d7aa43fb12042dc0510c4e9706d..5aff09d66cfef3c9addc1e3dedf9b0eefd7553dc 100644 (file)
--- a/src/URL.h
+++ b/src/URL.h
@@ -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
  */
 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 @@ 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 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 @@ private:
      * 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);
diff --git a/src/URLScheme.cc b/src/URLScheme.cc
deleted file mode 100644 (file)
index 6ccba69..0000000
+++ /dev/null
@@ -1,54 +0,0 @@
-
-/*
- * 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.
- *
- */
-
-#include "squid.h"
-#include "URLScheme.h"
-#include "wordlist.h"
-
-char const *
-URLScheme::const_str() const
-{
-    if (theScheme_ == AnyP::PROTO_UNKNOWN)
-        return "(unknown)";
-
-    static char out[BUFSIZ];
-    int p = 0;
-
-    if (theScheme_ > AnyP::PROTO_NONE && theScheme_ < AnyP::PROTO_MAX) {
-        const char *in = AnyP::ProtocolType_str[theScheme_];
-        for (; p < (BUFSIZ-1) && in[p] != '\0'; ++p)
-            out[p] = xtolower(in[p]);
-    }
-    out[p] = '\0';
-    return out;
-}
diff --git a/src/URLScheme.h b/src/URLScheme.h
deleted file mode 100644 (file)
index cb4fc5e..0000000
+++ /dev/null
@@ -1,74 +0,0 @@
-
-/*
- *
- * 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
-
-#include "anyp/ProtocolType.h"
-#if HAVE_IOSFWD
-#include <iosfwd>
-#endif
-
-/** This class represents a URL Scheme such as HTTPS, HTTP, WAIS etc.
- * It does not represent the PROTOCOL that such schemes refer to.
- */
-class URLScheme
-{
-
-public:
-    URLScheme() : theScheme_(AnyP::PROTO_NONE) {}
-    URLScheme(AnyP::ProtocolType const aScheme) : theScheme_(aScheme) {}
-    ~URLScheme() {}
-
-    operator AnyP::ProtocolType() const { return theScheme_; }
-
-    bool operator != (AnyP::ProtocolType const & aProtocol) const { return theScheme_ != aProtocol; }
-
-    /** Get a char string representation of the scheme.
-     * 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;
-
-private:
-    /// This is a typecode pointer into the enum/registry of protocols handled.
-    AnyP::ProtocolType theScheme_;
-};
-
-inline std::ostream &
-operator << (std::ostream &os, URLScheme const &scheme)
-{
-    os << scheme.const_str();
-    return os;
-}
-
-#endif /* SQUID_URLSCHEME_H */
index f0b6899a9c6b889f1171369f6e19b254e051a351..dcfe1bcf4a5baf45f5a71d9fab41c03946c57f77 100644 (file)
@@ -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)
index 2724a482ceae1b9398df14a06e7e44743f7ad2f7..39a428fe8048b5793bd00a8de22d23aecdb562f6 100644 (file)
@@ -10,7 +10,9 @@ libanyp_la_SOURCES = \
        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)
diff --git a/src/anyp/UriScheme.cc b/src/anyp/UriScheme.cc
new file mode 100644 (file)
index 0000000..36a873f
--- /dev/null
@@ -0,0 +1,24 @@
+/*
+ * DEBUG: section 23    URL Scheme parsing
+ * AUTHOR: Robert Collins, Amos Jeffries
+ */
+#include "squid.h"
+#include "anyp/UriScheme.h"
+
+char const *
+AnyP::UriScheme::c_str() const
+{
+    if (theScheme_ == AnyP::PROTO_UNKNOWN)
+        return "(unknown)";
+
+    static char out[BUFSIZ];
+    int p = 0;
+
+    if (theScheme_ > AnyP::PROTO_NONE && theScheme_ < AnyP::PROTO_MAX) {
+        const char *in = AnyP::ProtocolType_str[theScheme_];
+        for (; p < (BUFSIZ-1) && in[p] != '\0'; ++p)
+            out[p] = xtolower(in[p]);
+    }
+    out[p] = '\0';
+    return out;
+}
diff --git a/src/anyp/UriScheme.h b/src/anyp/UriScheme.h
new file mode 100644 (file)
index 0000000..98de13c
--- /dev/null
@@ -0,0 +1,49 @@
+#ifndef SQUID_ANYP_URISCHEME_H
+#define SQUID_ANYP_URISCHEME_H
+
+#include "anyp/ProtocolType.h"
+#if HAVE_IOSFWD
+#include <iosfwd>
+#endif
+
+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 UriScheme
+{
+public:
+    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 *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, AnyP::UriScheme const &scheme)
+{
+    os << scheme.c_str();
+    return os;
+}
+
+#endif /* SQUID_ANYP_URISCHEME_H */
index b01b4c0077a809e3dac71984fa4bed9e8b6114da..bc9a52ef36e2c71e1b6ca0afa2667013ac81d653 100644 (file)
@@ -9,6 +9,8 @@ namespace AnyP
 class PortCfg;
 typedef CbcPointer<PortCfg> PortCfgPointer;
 
+class UriScheme;
+
 } // namespace AnyP
 
 #endif /* _SQUID_SRC_ANYP_FORWARD_H */
index 7b1f453a458c83609d6436fdeba5f65a5794f6f6..95fcd154d768989c3c76195b1676daf7cfb4a2fc 100644 (file)
@@ -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 @@ parsePortSpecification(AnyP::PortCfg * s, char *token)
     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 @@ parsePortCfg(AnyP::PortCfg ** head, const char *optionName)
         // 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 @@ dump_generic_port(StoreEntry * e, const char *n, const AnyP::PortCfg * s)
 
         // 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");
index 37e916c1b59d0f8f49c534da3acab33c0f7f71ec..a52527e68271b7ae627fe075205ca7b7c8da64e3 100644 (file)
@@ -40,7 +40,6 @@
 #include "SquidConfig.h"
 #include "Store.h"
 #include "URL.h"
-#include "URLScheme.h"
 
 #if HAVE_MATH_H
 #include <math.h>
@@ -195,8 +194,8 @@ carpSelectParent(HttpRequest * request)
             //   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("://");
             }
index 0781d7d89056c443b1254bf62e0247673b707060..9fbf9e52a2282ebfc5666cebbb75430afe58c89e 100644 (file)
@@ -2120,7 +2120,7 @@ prepareAcceleratedURL(ConnStateData * conn, ClientHttpRequest *http, char *url,
                      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 @@ prepareAcceleratedURL(ConnStateData * conn, ClientHttpRequest *http, char *url,
             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 @@ prepareAcceleratedURL(ConnStateData * conn, ClientHttpRequest *http, char *url,
         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 @@ prepareTransparentURL(ConnStateData * conn, ClientHttpRequest *http, char *url,
         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 @@ prepareTransparentURL(ConnStateData * conn, ClientHttpRequest *http, char *url,
         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 @@ clientHttpConnectionsOpen(void)
 
 #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 @@ clientHttpsConnectionsOpen(void)
 
         // 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;
         }
 
index 6c25de0ae2542148fee02128ed17f66f9696268d..4d98ba2e1887942c0f58b73e7857d0eda4610c04 100644 (file)
@@ -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"
index c5063c73213e95572b460a2facc136058ccad095..8e858aaedd783bb2708ffab48cab87bba50f3a60 100644 (file)
@@ -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"
index 05275efaa8916a780f6439f2632c4de0e816e7ac..9901ffc2481d690d9b9bd153adb918a7af50919b 100644 (file)
@@ -60,7 +60,6 @@
 #include "Store.h"
 #include "tools.h"
 #include "URL.h"
-#include "URLScheme.h"
 #include "wordlist.h"
 
 #if USE_DELAY_POOLS
index 379d431e9d25aec330078506b9f2d644b8c63d6b..cb6649a359ef8f92052d1907c869c960d0e3cf4d 100644 (file)
@@ -22,17 +22,17 @@ testURL::setUp()
 }
 
 /*
- * 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 @@ testURL::testConstructScheme()
 void
 testURL::testDefaultConstructor()
 {
-    URLScheme aScheme;
+    AnyP::UriScheme aScheme;
     URL aUrl;
     CPPUNIT_ASSERT_EQUAL(aScheme, aUrl.getScheme());
 
similarity index 52%
rename from src/tests/testURLScheme.cc
rename to src/tests/testUriScheme.cc
index b4709f90e880caadc045922b18af1bc21476c760..680f0accc259f6a5d3510e2a6061a5b9de922d8f 100644 (file)
@@ -4,16 +4,16 @@
 
 #include <cppunit/TestAssert.h>
 
+#include "anyp/UriScheme.h"
 #include "Mem.h"
 #include "SquidString.h"
-#include "testURLScheme.h"
-#include "URLScheme.h"
+#include "tests/testUriScheme.h"
 
 #if HAVE_SSTREAM
 #include <sstream>
 #endif
 
-CPPUNIT_TEST_SUITE_REGISTRATION( testURLScheme );
+CPPUNIT_TEST_SUITE_REGISTRATION( testUriScheme );
 
 #if 0
 /*
@@ -47,58 +47,58 @@ testHttpRequestMethod::testConstructCharStartEnd()
 #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<AnyP::ProtocolType>(URLScheme());
+    AnyP::ProtocolType protocol = static_cast<AnyP::ProtocolType>(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 @@ testURLScheme::testConstructprotocol_t()
  * 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);
similarity index 77%
rename from src/tests/testURLScheme.h
rename to src/tests/testUriScheme.h
index fe8ba2b7de8a5a776817ea4bfdd35c03049eec91..d996ee12b2287052da451d6488a29ee57940864d 100644 (file)
@@ -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 <cppunit/extensions/HelperMacros.h>
 
 /*
- * 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 @@ class testURLScheme : public CPPUNIT_NS::TestFixture
     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 @@ protected:
     void testConstructCharStartEnd();
 #endif
 
-    void testConst_str();
+    void testC_str();
     void testDefaultConstructor();
     void testEqualprotocol_t();
     void testNotEqualprotocol_t();
index e740ec5dc00554b947e90a967a1075f4bc0b6a59..0268467f8e4a009e2799ad8fc33e9819ed689e29 100644 (file)
@@ -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 @@ urlCanonical(HttpRequest * request)
         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 @@ urlCanonicalClean(const HttpRequest * request)
             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 @@ urlMakeAbsolute(const HttpRequest * req, const char *relUrl)
 
     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 @@ urlMakeAbsolute(const HttpRequest * req, const char *relUrl)
                          );
     } 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 @@ URLHostName::extract(char const *aUrl)
 
     return Host;
 }
-
-URL::URL() : scheme()
-{}
-
-URL::URL(URLScheme const &aScheme): scheme(aScheme)
-{}