]>
Commit | Line | Data |
---|---|---|
985c86bc | 1 | /* |
bbc27441 | 2 | * Copyright (C) 1996-2014 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" |
985c86bc | 13 | #include "MemPool.h" |
985c86bc | 14 | |
63be0a78 | 15 | /** |
16 | \ingroup POD | |
17 | * | |
18 | * The URL class represents a Uniform Resource Location | |
19 | */ | |
985c86bc | 20 | class URL |
21 | { | |
985c86bc | 22 | public: |
985c86bc | 23 | MEMPROXY_CLASS(URL); |
1ca54a54 AJ |
24 | URL() : scheme_() {} |
25 | URL(AnyP::UriScheme const &aScheme) : scheme_(aScheme) {} | |
4e3f4dc7 AJ |
26 | |
27 | void clear() { | |
28 | scheme_=AnyP::PROTO_NONE; | |
29 | } | |
30 | ||
1ca54a54 | 31 | AnyP::UriScheme const & getScheme() const {return scheme_;} |
985c86bc | 32 | |
4e3f4dc7 AJ |
33 | /// convert the URL scheme to that given |
34 | void setScheme(const AnyP::ProtocolType &p) {scheme_=p;} | |
35 | ||
985c86bc | 36 | private: |
63be0a78 | 37 | /** |
38 | \par | |
39 | * The scheme of this URL. This has the 'type code' smell about it. | |
26ac0430 AJ |
40 | * In future we may want to make the methods that dispatch based on |
41 | * the scheme virtual and have a class per protocol. | |
63be0a78 | 42 | \par |
43 | * On the other hand, having Protocol as an explicit concept is useful, | |
985c86bc | 44 | * see for instance the ACLProtocol acl type. One way to represent this |
26ac0430 | 45 | * is to have one prototype URL with no host etc for each scheme, |
985c86bc | 46 | * another is to have an explicit scheme class, and then each URL class |
26ac0430 | 47 | * could be a subclass of the scheme. Another way is one instance of |
1ca54a54 | 48 | * a AnyP::UriScheme class instance for each URL scheme we support, and one URL |
985c86bc | 49 | * class for each manner of treating the scheme : a Hierarchical URL, a |
63be0a78 | 50 | * non-hierarchical URL etc. |
51 | \par | |
985c86bc | 52 | * Deferring the decision, its a type code for now. RBC 20060507. |
63be0a78 | 53 | \par |
26ac0430 | 54 | * In order to make taking any of these routes easy, scheme is private |
985c86bc | 55 | * and immutable, only settable at construction time, |
56 | */ | |
4e3f4dc7 | 57 | AnyP::UriScheme scheme_; |
985c86bc | 58 | }; |
59 | ||
60 | MEMPROXY_CLASS_INLINE(URL); | |
61 | ||
fc54b8d2 FC |
62 | class HttpRequest; |
63 | class HttpRequestMethod; | |
64 | ||
8a648e8d FC |
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); | |
fc54b8d2 | 80 | |
985c86bc | 81 | #endif /* SQUID_SRC_URL_H_H */ |