]>
Commit | Line | Data |
---|---|---|
5dee515e | 1 | /* |
4ac4a490 | 2 | * Copyright (C) 1996-2017 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 | */ |
8 | ||
9 | #ifndef SQUID_ACLREQUESTHEADERSTRATEGY_H | |
10 | #define SQUID_ACLREQUESTHEADERSTRATEGY_H | |
127dce76 AR |
11 | #include "acl/Acl.h" |
12 | #include "acl/Data.h" | |
602d9612 | 13 | #include "acl/FilledChecklist.h" |
127dce76 | 14 | #include "acl/Strategy.h" |
a2ac85d9 | 15 | #include "HttpRequest.h" |
5dee515e | 16 | |
789217a2 | 17 | template <Http::HdrType header> |
b0dd28ba | 18 | class ACLRequestHeaderStrategy : public ACLStrategy<char const *> |
5dee515e | 19 | { |
62e76326 | 20 | |
21 | public: | |
33810b1d | 22 | virtual int match (ACLData<char const *> * &, ACLFilledChecklist *, ACLFlags &); |
5dee515e | 23 | virtual bool requiresRequest() const {return true;} |
62e76326 | 24 | |
5dee515e | 25 | static ACLRequestHeaderStrategy *Instance(); |
26 | /* Not implemented to prevent copies of the instance. */ | |
27 | /* Not private to prevent brain dead g+++ warnings about | |
28 | * private constructors with no friends */ | |
29 | ACLRequestHeaderStrategy(ACLRequestHeaderStrategy const &); | |
62e76326 | 30 | |
31 | private: | |
b6012c1a | 32 | static ACLRequestHeaderStrategy *Instance_; |
26ac0430 | 33 | ACLRequestHeaderStrategy() {} |
62e76326 | 34 | |
5dee515e | 35 | ACLRequestHeaderStrategy&operator=(ACLRequestHeaderStrategy const &); |
36 | }; | |
37 | ||
789217a2 | 38 | template <Http::HdrType header> |
5dee515e | 39 | int |
33810b1d | 40 | ACLRequestHeaderStrategy<header>::match (ACLData<char const *> * &data, ACLFilledChecklist *checklist, ACLFlags &) |
5dee515e | 41 | { |
a9925b40 | 42 | char const *theHeader = checklist->request->header.getStr(header); |
62e76326 | 43 | |
5dee515e | 44 | if (NULL == theHeader) |
62e76326 | 45 | return 0; |
46 | ||
5dee515e | 47 | return data->match(theHeader); |
48 | } | |
49 | ||
789217a2 | 50 | template <Http::HdrType header> |
5dee515e | 51 | ACLRequestHeaderStrategy<header> * |
52 | ACLRequestHeaderStrategy<header>::Instance() | |
53 | { | |
b6012c1a | 54 | if (!Instance_) |
55 | Instance_ = new ACLRequestHeaderStrategy<header>; | |
56 | ||
57 | return Instance_; | |
5dee515e | 58 | } |
59 | ||
789217a2 | 60 | template <Http::HdrType header> |
edb9bfd5 | 61 | ACLRequestHeaderStrategy<header> * ACLRequestHeaderStrategy<header>::Instance_ = NULL; |
5dee515e | 62 | |
63 | #endif /* SQUID_REQUESTHEADERSTRATEGY_H */ | |
f53969cc | 64 |