]> git.ipfire.org Git - thirdparty/squid.git/blob - src/acl/RequestHeaderStrategy.h
Source Format Enforcement (#1234)
[thirdparty/squid.git] / src / acl / RequestHeaderStrategy.h
1 /*
2 * Copyright (C) 1996-2023 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_ACLREQUESTHEADERSTRATEGY_H
10 #define SQUID_ACLREQUESTHEADERSTRATEGY_H
11 #include "acl/Acl.h"
12 #include "acl/Data.h"
13 #include "acl/FilledChecklist.h"
14 #include "acl/Strategy.h"
15 #include "HttpRequest.h"
16
17 template <Http::HdrType header>
18 class ACLRequestHeaderStrategy : public ACLStrategy<char const *>
19 {
20
21 public:
22 int match (ACLData<char const *> * &, ACLFilledChecklist *) override;
23 bool requiresRequest() const override {return true;}
24 };
25
26 template <Http::HdrType header>
27 int
28 ACLRequestHeaderStrategy<header>::match (ACLData<char const *> * &data, ACLFilledChecklist *checklist)
29 {
30 char const *theHeader = checklist->request->header.getStr(header);
31
32 if (nullptr == theHeader)
33 return 0;
34
35 return data->match(theHeader);
36 }
37
38 #endif /* SQUID_REQUESTHEADERSTRATEGY_H */
39