]> git.ipfire.org Git - thirdparty/squid.git/blob - src/URL.h
Merge from trunk rev.13584
[thirdparty/squid.git] / src / URL.h
1 /*
2 * Copyright (C) 1996-2014 The Squid Software Foundation and contributors
3 *
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.
7 */
8
9 #ifndef SQUID_SRC_URL_H
10 #define SQUID_SRC_URL_H
11
12 #include "anyp/UriScheme.h"
13 #include "MemPool.h"
14
15 /**
16 \ingroup POD
17 *
18 * The URL class represents a Uniform Resource Location
19 */
20 class URL
21 {
22 public:
23 MEMPROXY_CLASS(URL);
24 URL() : scheme_() {}
25 URL(AnyP::UriScheme const &aScheme) : scheme_(aScheme) {}
26
27 void clear() {
28 scheme_=AnyP::PROTO_NONE;
29 }
30
31 AnyP::UriScheme const & getScheme() const {return scheme_;}
32
33 /// convert the URL scheme to that given
34 void setScheme(const AnyP::ProtocolType &p) {scheme_=p;}
35
36 private:
37 /**
38 \par
39 * The scheme of this URL. This has the 'type code' smell about it.
40 * In future we may want to make the methods that dispatch based on
41 * the scheme virtual and have a class per protocol.
42 \par
43 * On the other hand, having Protocol as an explicit concept is useful,
44 * see for instance the ACLProtocol acl type. One way to represent this
45 * is to have one prototype URL with no host etc for each scheme,
46 * another is to have an explicit scheme class, and then each URL class
47 * could be a subclass of the scheme. Another way is one instance of
48 * a AnyP::UriScheme class instance for each URL scheme we support, and one URL
49 * class for each manner of treating the scheme : a Hierarchical URL, a
50 * non-hierarchical URL etc.
51 \par
52 * Deferring the decision, its a type code for now. RBC 20060507.
53 \par
54 * In order to make taking any of these routes easy, scheme is private
55 * and immutable, only settable at construction time,
56 */
57 AnyP::UriScheme scheme_;
58 };
59
60 MEMPROXY_CLASS_INLINE(URL);
61
62 class HttpRequest;
63 class HttpRequestMethod;
64
65 AnyP::ProtocolType urlParseProtocol(const char *, const char *e = NULL);
66 void urlInitialize(void);
67 HttpRequest *urlParse(const HttpRequestMethod&, char *, HttpRequest *request = NULL);
68 const char *urlCanonical(HttpRequest *);
69 char *urlCanonicalClean(const HttpRequest *);
70 const char *urlCanonicalFakeHttps(const HttpRequest * request);
71 bool urlIsRelative(const char *);
72 char *urlMakeAbsolute(const HttpRequest *, const char *);
73 char *urlRInternal(const char *host, unsigned short port, const char *dir, const char *name);
74 char *urlInternal(const char *dir, const char *name);
75 int matchDomainName(const char *host, const char *domain);
76 int urlCheckRequest(const HttpRequest *);
77 int urlDefaultPort(AnyP::ProtocolType p);
78 char *urlHostname(const char *url);
79 void urlExtMethodConfigure(void);
80
81 #endif /* SQUID_SRC_URL_H_H */