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.
$(UNLINKDSOURCE) \
url.cc \
URL.h \
- URLScheme.cc \
- URLScheme.h \
urn.h \
urn.cc \
wccp.h \
tests/testMain.cc \
tests/stub_time.cc \
url.cc \
- URLScheme.cc \
wordlist.h \
wordlist.cc
nodist_tests_testHttpReply_SOURCES=\
tests/stub_time.cc \
url.cc \
URL.h \
- URLScheme.cc \
- URLScheme.h \
Mem.h \
tests/stub_mem.cc \
MemBuf.cc \
MemStore.cc \
$(UNLINKDSOURCE) \
url.cc \
- URLScheme.cc \
urn.h \
urn.cc \
wccp2.h \
tests/stub_time.cc \
$(UNLINKDSOURCE) \
url.cc \
- URLScheme.cc \
$(WIN32_SOURCE) \
wordlist.h \
wordlist.cc \
MemStore.cc \
$(UNLINKDSOURCE) \
url.cc \
- URLScheme.cc \
urn.h \
urn.cc \
wccp2.h \
MemStore.cc \
$(UNLINKDSOURCE) \
url.cc \
- URLScheme.cc \
urn.h \
urn.cc \
wccp2.h \
tests/stub_tunnel.cc \
$(UNLINKDSOURCE) \
url.cc \
- URLScheme.cc \
urn.h \
urn.cc \
wccp2.h \
tests/stub_SwapDir.cc \
MemStore.cc \
url.cc \
- URLScheme.cc \
urn.h \
urn.cc \
wccp2.h \
tests/TestSwapDir.h \
tests/stub_time.cc \
url.cc \
- URLScheme.cc \
wordlist.h \
wordlist.cc
tests/testStoreSupport.cc \
tests/testStoreSupport.h \
time.cc \
- URLScheme.cc \
wordlist.h \
wordlist.cc \
$(DISKIO_SOURCE)
tests/stub_tools.cc \
time.cc \
url.cc \
- URLScheme.cc \
wordlist.h \
wordlist.cc \
$(DELAY_POOL_SOURCE) \
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 \
tools.cc \
tests/stub_tunnel.cc \
url.cc \
- URLScheme.cc \
urn.h \
urn.cc \
wccp2.h \
#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:
/**
* 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
* 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);
+++ /dev/null
-
-/*
- * 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;
-}
+++ /dev/null
-
-/*
- *
- * 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 */
#include "acl/ProtocolData.h"
#include "cache_cf.h"
#include "Debug.h"
-#include "URLScheme.h"
#include "wordlist.h"
ACLProtocolData::ACLProtocolData() : values (NULL)
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)
--- /dev/null
+/*
+ * 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;
+}
--- /dev/null
+#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 */
class PortCfg;
typedef CbcPointer<PortCfg> PortCfgPointer;
+class UriScheme;
+
} // namespace AnyP
#endif /* _SQUID_SRC_ANYP_FORWARD_H */
#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"
#include "StoreFileSystem.h"
#include "SwapDir.h"
#include "tools.h"
-#include "URLScheme.h"
#include "wordlist.h"
/* wccp2 has its own conditional definitions */
#include "wccp2.h"
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 */
// 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)
// 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");
#include "SquidConfig.h"
#include "Store.h"
#include "URL.h"
-#include "URLScheme.h"
#if HAVE_MATH_H
#include <math.h>
// 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("://");
}
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 */) {
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);
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 << "'");
}
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. */
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 << "'");
}
#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;
}
// 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;
}
#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"
#include "Store.h"
#include "tools.h"
#include "URL.h"
-#include "URLScheme.h"
#include "wordlist.h"
#if USE_SSL
#include "ssl/support.h"
#include "Store.h"
#include "tools.h"
#include "URL.h"
-#include "URLScheme.h"
#include "wordlist.h"
#if USE_DELAY_POOLS
}
/*
- * 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());
}
void
testURL::testDefaultConstructor()
{
- URLScheme aScheme;
+ AnyP::UriScheme aScheme;
URL aUrl;
CPPUNIT_ASSERT_EQUAL(aScheme, aUrl.getScheme());
#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
/*
#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);
}
* 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);
-#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 );
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();
void testConstructCharStartEnd();
#endif
- void testConst_str();
+ void testC_str();
void testDefaultConstructor();
void testEqualprotocol_t();
void testNotEqualprotocol_t();
#include "SquidConfig.h"
#include "SquidString.h"
#include "URL.h"
-#include "URLScheme.h"
static HttpRequest *urlParseFinish(const HttpRequestMethod& method,
const AnyP::ProtocolType protocol,
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(),
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,
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(),
);
} else {
urllen = snprintf(urlbuf, MAX_URL, "%s://%s%s%s",
- sch.const_str(),
+ sch.c_str(),
req->login,
*req->login ? "@" : null_string,
req->GetHost()
return Host;
}
-
-URL::URL() : scheme()
-{}
-
-URL::URL(URLScheme const &aScheme): scheme(aScheme)
-{}