]>
Commit | Line | Data |
---|---|---|
5dee515e | 1 | /* |
bde978a6 | 2 | * Copyright (C) 1996-2015 The Squid Software Foundation and contributors |
5dee515e | 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. | |
5dee515e | 7 | */ |
bbc27441 | 8 | |
b0dd28ba | 9 | #ifndef SQUID_ACLREPLYHEADERSTRATEGY_H |
10 | #define SQUID_ACLREPLYHEADERSTRATEGY_H | |
e1f7507e AJ |
11 | |
12 | class ACLChecklist; | |
13 | ||
127dce76 AR |
14 | #include "acl/Acl.h" |
15 | #include "acl/Data.h" | |
127dce76 | 16 | #include "acl/FilledChecklist.h" |
602d9612 | 17 | #include "acl/Strategy.h" |
7e6b941f | 18 | #include "HttpReply.h" |
5dee515e | 19 | |
b0dd28ba | 20 | template <http_hdr_type header> |
b0dd28ba | 21 | class ACLReplyHeaderStrategy : public ACLStrategy<char const *> |
62e76326 | 22 | { |
23 | ||
24 | public: | |
33810b1d | 25 | virtual int match (ACLData<char const *> * &, ACLFilledChecklist *, ACLFlags &); |
b0dd28ba | 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: | |
b6012c1a | 35 | static ACLReplyHeaderStrategy *Instance_; |
26ac0430 | 36 | ACLReplyHeaderStrategy() {} |
62e76326 | 37 | |
b0dd28ba | 38 | ACLReplyHeaderStrategy&operator=(ACLReplyHeaderStrategy const &); |
39 | }; | |
40 | ||
41 | template <http_hdr_type header> | |
42 | int | |
33810b1d | 43 | ACLReplyHeaderStrategy<header>::match (ACLData<char const *> * &data, ACLFilledChecklist *checklist, ACLFlags &) |
b0dd28ba | 44 | { |
a9925b40 | 45 | char const *theHeader = checklist->reply->header.getStr(header); |
b0dd28ba | 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 | { | |
b6012c1a | 57 | if (!Instance_) |
58 | Instance_ = new ACLReplyHeaderStrategy<header>; | |
59 | ||
60 | return Instance_; | |
b0dd28ba | 61 | } |
62e76326 | 62 | |
b0dd28ba | 63 | template <http_hdr_type header> |
edb9bfd5 | 64 | ACLReplyHeaderStrategy<header> * ACLReplyHeaderStrategy<header>::Instance_ = NULL; |
5dee515e | 65 | |
b0dd28ba | 66 | #endif /* SQUID_REPLYHEADERSTRATEGY_H */ |
f53969cc | 67 |