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