#include "sbuf/StringConvert.h"
#include "SquidConfig.h"
#include "Store.h"
-#include "URL.h"
#if USE_AUTH
#include "auth/UserRequest.h"
#ifndef SQUID_HTTPREQUEST_H
#define SQUID_HTTPREQUEST_H
+#include "anyp/Uri.h"
#include "base/CbcPointer.h"
#include "dns/forward.h"
#include "err_type.h"
#include "MasterXaction.h"
#include "Notes.h"
#include "RequestFlags.h"
-#include "URL.h"
#if USE_AUTH
#include "auth/UserRequest.h"
public:
HttpRequestMethod method;
- URL url; ///< the request URI
+ AnyP::Uri url; ///< the request URI
private:
#if USE_ADAPTATION
tunnel.cc \
typedefs.h \
$(UNLINKDSOURCE) \
- url.cc \
- URL.h \
urn.h \
urn.cc \
wccp.h \
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=\
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
tests/stub_SwapDir.cc \
MemStore.cc \
$(UNLINKDSOURCE) \
- tests/stub_url.cc \
+ tests/stub_libanyp.cc \
urn.h \
urn.cc \
wccp2.h \
tests/testStoreSupport.h \
tests/stub_time.cc \
$(UNLINKDSOURCE) \
- tests/stub_url.cc \
+ tests/stub_libanyp.cc \
$(WIN32_SOURCE) \
wordlist.h \
wordlist.cc \
tests/stub_tunnel.cc \
MemStore.cc \
$(UNLINKDSOURCE) \
- tests/stub_url.cc \
+ tests/stub_libanyp.cc \
urn.h \
urn.cc \
wccp2.h \
tests/stub_tunnel.cc \
MemStore.cc \
$(UNLINKDSOURCE) \
- tests/stub_url.cc \
+ tests/stub_libanyp.cc \
urn.h \
urn.cc \
wccp2.h \
tools.cc \
tests/stub_tunnel.cc \
$(UNLINKDSOURCE) \
- tests/stub_url.cc \
+ tests/stub_libanyp.cc \
urn.h \
urn.cc \
wccp2.h \
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 = \
tests/stub_tunnel.cc \
tests/stub_SwapDir.cc \
MemStore.cc \
- url.cc \
urn.h \
urn.cc \
wccp2.h \
tests/TestSwapDir.cc \
tests/TestSwapDir.h \
tests/stub_time.cc \
- tests/stub_url.cc \
+ tests/stub_libanyp.cc \
wordlist.h \
wordlist.cc
HttpHdrCc.cc \
HttpHdrSc.cc \
HttpHdrScTarget.cc \
- tests/stub_url.cc \
+ tests/stub_libanyp.cc \
StatCounters.h \
StatCounters.cc \
StatHist.h \
tools.h \
tests/stub_tools.cc \
time.cc \
- tests/stub_url.cc \
+ tests/stub_libanyp.cc \
wordlist.h \
wordlist.cc \
$(DELAY_POOL_SOURCE) \
tools.h \
tools.cc \
tests/stub_tunnel.cc \
- url.cc \
urn.h \
urn.cc \
wccp2.h \
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;
#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<class T>
#include "ssl/bio.h"
#include "ssl/ServerBump.h"
#include "ssl/support.h"
-#include "URL.h"
// Compare function for tree search algorithms
static int
#include "acl/Url.h"
#include "HttpRequest.h"
#include "rfc1738.h"
-#include "src/URL.h"
int
ACLUrlStrategy::match (ACLData<char const *> * &data, ACLFilledChecklist *checklist)
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 << ": " <<
#include "adaptation/ecap/MessageRep.h"
#include "adaptation/ecap/XactionRep.h"
#include "base/TextException.h"
-#include "URL.h"
/* HeaderRep */
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);
#include "HttpReply.h"
#include "MasterXaction.h"
#include "SquidTime.h"
-#include "URL.h"
// flow and terminology:
// HTTP| --> receive --> encode --> write --> |network
ProtocolType.h \
ProtocolVersion.h \
TrafficMode.h \
+ Uri.cc \
+ Uri.h \
UriScheme.cc \
UriScheme.h
/* 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"
;
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;
}
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 "/"
* 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);
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) {
/// 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,
}
void
-URL::touch()
+AnyP::Uri::touch()
{
absolute_.clear();
authorityHttp_.clear();
}
SBuf &
-URL::authority(bool requirePort) const
+AnyP::Uri::authority(bool requirePort) const
{
if (authorityHttp_.isEmpty()) {
}
SBuf &
-URL::absolute() const
+AnyP::Uri::absolute() const
{
if (absolute_.isEmpty()) {
// TODO: most URL will be much shorter, avoid allocating this much
// 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;
return Host;
}
-URL::URL(AnyP::UriScheme const &aScheme) :
+AnyP::Uri::Uri(AnyP::UriScheme const &aScheme) :
scheme_(aScheme),
hostIsNumeric_(false),
port_(0)
* 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"
#include <iosfwd>
+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_));
/// the static '/' default URL-path
static const SBuf &SlashPath();
- /// the static '*' pseudo-URL
+ /// the static '*' pseudo-URI
static const SBuf &Asterisk();
/**
* 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_;
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)
return os;
}
+/* Deprecated functions for Legacy code handling URLs */
+
class HttpRequest;
-class HttpRequestMethod;
void urlInitialize(void);
char *urlCanonicalClean(const HttpRequest *);
char *urlHostname(const char *url);
void urlExtMethodConfigure(void);
-#endif /* SQUID_SRC_URL_H_H */
+#endif /* SQUID_SRC_ANYP_URI_H */
class PortCfg;
typedef RefCount<PortCfg> PortCfgPointer;
+class Uri;
class UriScheme;
} // namespace AnyP
#include "PeerSelectState.h"
#include "SquidConfig.h"
#include "Store.h"
-#include "URL.h"
#include <cmath>
#include "Store.h"
#include "TimeOrTag.h"
#include "tools.h"
-#include "URL.h"
#if USE_AUTH
#include "auth/UserRequest.h"
#include "Store.h"
#include "StrList.h"
#include "tools.h"
-#include "URL.h"
#if USE_AUTH
#include "auth/UserRequest.h"
#endif
#include "Store.h"
#include "StrList.h"
#include "tools.h"
-#include "URL.h"
#include "wordlist.h"
#if USE_AUTH
#include "auth/UserRequest.h"
// 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;
#include "StatCounters.h"
#include "Store.h"
#include "tools.h"
-#include "URL.h"
#if USE_ADAPTATION
#include "adaptation/AccessCheck.h"
#include "StatCounters.h"
#include "Store.h"
#include "tools.h"
-#include "URL.h"
#include "util.h"
#include "wordlist.h"
#include "SquidConfig.h"
#include "Store.h"
#include "tools.h"
-#include "URL.h"
#include "wordlist.h"
#if USE_AUTH
#include "auth/UserRequest.h"
#include "SquidTime.h"
#include "Store.h"
#include "tools.h"
-#include "URL.h"
#include "wordlist.h"
#if USE_OPENSSL
#include "ssl/ServerBump.h"
#include "SquidTime.h"
#include "Store.h"
#include "tools.h"
-#include "URL.h"
#if USE_OPENSSL
#include "ssl/ErrorDetail.h"
#include "ssl/ServerBump.h"
#include "store_key_md5.h"
#include "StoreClient.h"
#include "tools.h"
-#include "URL.h"
typedef struct _Countstr Countstr;
#include "Store.h"
#include "StrList.h"
#include "tools.h"
-#include "URL.h"
#include "util.h"
#if USE_AUTH
}
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;
#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"
class netdbEntry;
class PeerSelector;
class StoreEntry;
-class URL;
class net_db_name:
public hash_link /* must be first */
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 *);
#include "SquidTime.h"
#include "Store.h"
#include "tools.h"
-#include "URL.h"
#include "util.h"
#include "wordlist.h"
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);
#include "StoreFileSystem.h"
#include "tools.h"
#include "unlinkd.h"
-#include "URL.h"
#include "wccp.h"
#include "wccp2.h"
#include "WinSvc.h"
#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
}
peer_t
-neighborType(const CachePeer * p, const URL &url)
+neighborType(const CachePeer * p, const AnyP::Uri &url)
{
const NeighborTypeDomainList *d = NULL;
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;
#ifndef SQUID_NEIGHBORS_H_
#define SQUID_NEIGHBORS_H_
+#include "anyp/forward.h"
#include "enums.h"
#include "ICP.h"
#include "lookup_t.h"
class HttpRequestMethod;
class CachePeer;
class StoreEntry;
-class URL;
class PeerSelector;
CachePeer *getFirstPeer(void);
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 *);
#include "SquidConfig.h"
#include "SquidTime.h"
#include "Store.h"
-#include "URL.h"
/**
* A CachePeer which has been selected as a possible destination.
#include "SquidConfig.h"
#include "SquidTime.h"
#include "Store.h"
-#include "URL.h"
#include "util.h"
typedef enum {
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()) {
/* 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);
#include "acl/FilledChecklist.h"
#include "anyp/PortCfg.h"
+#include "anyp/Uri.h"
#include "fatal.h"
#include "fd.h"
#include "fde.h"
#include "ssl/ErrorDetail.h"
#include "ssl/gadgets.h"
#include "ssl/support.h"
-#include "URL.h"
#include <cerrno>
#include "HttpRequest.h"
#include "md5.h"
#include "store_key_md5.h"
-#include "URL.h"
static cache_key null_key[SQUID_MD5_DIGEST_LENGTH];
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 \
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
#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)
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
#include <cppunit/TestAssert.h>
+#include "anyp/Uri.h"
#include "Debug.h"
-#include "testURL.h"
+#include "tests/testURL.h"
#include "unitTestMain.h"
-#include "URL.h"
#include <sstream>
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());
}
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;
}
#include "Store.h"
#include "StoreClient.h"
#include "tools.h"
-#include "URL.h"
#include "urn.h"
#define URN_REQBUF_SZ 4096
}
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));