]> git.ipfire.org Git - thirdparty/squid.git/blame - src/URL.h
SourceFormat Enforcement
[thirdparty/squid.git] / src / URL.h
CommitLineData
985c86bc 1/*
bde978a6 2 * Copyright (C) 1996-2015 The Squid Software Foundation and contributors
985c86bc 3 *
bbc27441
AJ
4 * Squid software is distributed under GPLv2+ license and includes
5 * contributions from numerous individuals and organizations.
6 * Please see the COPYING and CONTRIBUTORS files for details.
985c86bc 7 */
8
9#ifndef SQUID_SRC_URL_H
10#define SQUID_SRC_URL_H
11
1ca54a54 12#include "anyp/UriScheme.h"
92d6986d 13#include "SBuf.h"
985c86bc 14
63be0a78 15/**
63be0a78 16 * The URL class represents a Uniform Resource Location
17 */
985c86bc 18class URL
19{
985c86bc 20 MEMPROXY_CLASS(URL);
741c2986
AJ
21
22public:
1ca54a54
AJ
23 URL() : scheme_() {}
24 URL(AnyP::UriScheme const &aScheme) : scheme_(aScheme) {}
4e3f4dc7
AJ
25
26 void clear() {
27 scheme_=AnyP::PROTO_NONE;
28 }
29
1ca54a54 30 AnyP::UriScheme const & getScheme() const {return scheme_;}
985c86bc 31
4e3f4dc7
AJ
32 /// convert the URL scheme to that given
33 void setScheme(const AnyP::ProtocolType &p) {scheme_=p;}
34
92d6986d
AJ
35 void userInfo(const SBuf &s) {userInfo_=s;}
36 const SBuf &userInfo() const {return userInfo_;}
37
2e260208
AJ
38 /// the static '*' pseudo-URL
39 static const SBuf &Asterisk();
40
985c86bc 41private:
63be0a78 42 /**
43 \par
44 * The scheme of this URL. This has the 'type code' smell about it.
26ac0430
AJ
45 * In future we may want to make the methods that dispatch based on
46 * the scheme virtual and have a class per protocol.
63be0a78 47 \par
48 * On the other hand, having Protocol as an explicit concept is useful,
985c86bc 49 * see for instance the ACLProtocol acl type. One way to represent this
26ac0430 50 * is to have one prototype URL with no host etc for each scheme,
985c86bc 51 * another is to have an explicit scheme class, and then each URL class
26ac0430 52 * could be a subclass of the scheme. Another way is one instance of
1ca54a54 53 * a AnyP::UriScheme class instance for each URL scheme we support, and one URL
985c86bc 54 * class for each manner of treating the scheme : a Hierarchical URL, a
63be0a78 55 * non-hierarchical URL etc.
56 \par
985c86bc 57 * Deferring the decision, its a type code for now. RBC 20060507.
63be0a78 58 \par
26ac0430 59 * In order to make taking any of these routes easy, scheme is private
985c86bc 60 * and immutable, only settable at construction time,
61 */
4e3f4dc7 62 AnyP::UriScheme scheme_;
92d6986d
AJ
63
64 SBuf userInfo_; // aka 'URL-login'
985c86bc 65};
66
fc54b8d2
FC
67class HttpRequest;
68class HttpRequestMethod;
69
8a648e8d
FC
70AnyP::ProtocolType urlParseProtocol(const char *, const char *e = NULL);
71void urlInitialize(void);
72HttpRequest *urlParse(const HttpRequestMethod&, char *, HttpRequest *request = NULL);
73const char *urlCanonical(HttpRequest *);
74char *urlCanonicalClean(const HttpRequest *);
75const char *urlCanonicalFakeHttps(const HttpRequest * request);
76bool urlIsRelative(const char *);
77char *urlMakeAbsolute(const HttpRequest *, const char *);
78char *urlRInternal(const char *host, unsigned short port, const char *dir, const char *name);
79char *urlInternal(const char *dir, const char *name);
80int matchDomainName(const char *host, const char *domain);
81int urlCheckRequest(const HttpRequest *);
82int urlDefaultPort(AnyP::ProtocolType p);
83char *urlHostname(const char *url);
84void urlExtMethodConfigure(void);
fc54b8d2 85
985c86bc 86#endif /* SQUID_SRC_URL_H_H */
f53969cc 87