]> git.ipfire.org Git - thirdparty/squid.git/blob - src/acl/ReplyHeaderStrategy.h
SourceFormat Enforcement
[thirdparty/squid.git] / src / acl / ReplyHeaderStrategy.h
1 /*
2 * Copyright (C) 1996-2015 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_ACLREPLYHEADERSTRATEGY_H
10 #define SQUID_ACLREPLYHEADERSTRATEGY_H
11
12 class ACLChecklist;
13
14 #include "acl/Acl.h"
15 #include "acl/Data.h"
16 #include "acl/FilledChecklist.h"
17 #include "acl/Strategy.h"
18 #include "HttpReply.h"
19
20 template <http_hdr_type header>
21 class ACLReplyHeaderStrategy : public ACLStrategy<char const *>
22 {
23
24 public:
25 virtual int match (ACLData<char const *> * &, ACLFilledChecklist *, ACLFlags &);
26 virtual bool requiresReply() const {return true;}
27
28 static ACLReplyHeaderStrategy *Instance();
29 /* Not implemented to prevent copies of the instance. */
30 /* Not private to prevent brain dead g+++ warnings about
31 * private constructors with no friends */
32 ACLReplyHeaderStrategy(ACLReplyHeaderStrategy const &);
33
34 private:
35 static ACLReplyHeaderStrategy *Instance_;
36 ACLReplyHeaderStrategy() {}
37
38 ACLReplyHeaderStrategy&operator=(ACLReplyHeaderStrategy const &);
39 };
40
41 template <http_hdr_type header>
42 int
43 ACLReplyHeaderStrategy<header>::match (ACLData<char const *> * &data, ACLFilledChecklist *checklist, ACLFlags &)
44 {
45 char const *theHeader = checklist->reply->header.getStr(header);
46
47 if (NULL == theHeader)
48 return 0;
49
50 return data->match(theHeader);
51 }
52
53 template <http_hdr_type header>
54 ACLReplyHeaderStrategy<header> *
55 ACLReplyHeaderStrategy<header>::Instance()
56 {
57 if (!Instance_)
58 Instance_ = new ACLReplyHeaderStrategy<header>;
59
60 return Instance_;
61 }
62
63 template <http_hdr_type header>
64 ACLReplyHeaderStrategy<header> * ACLReplyHeaderStrategy<header>::Instance_ = NULL;
65
66 #endif /* SQUID_REPLYHEADERSTRATEGY_H */
67