RequestHeaderStrategy.h
Go to the documentation of this file.
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_SRC_ACL_REQUESTHEADERSTRATEGY_H
10 #define SQUID_SRC_ACL_REQUESTHEADERSTRATEGY_H
11 
12 #include "acl/Data.h"
13 #include "acl/FilledChecklist.h"
14 #include "acl/ParameterizedNode.h"
15 #include "HttpRequest.h"
16 
17 namespace Acl
18 {
19 
21 template <Http::HdrType header>
22 class RequestHeaderCheck: public ParameterizedNode< ACLData<const char *> >
23 {
24 public:
25  /* Acl::Node API */
26  int match(ACLChecklist *) override;
27  bool requiresRequest() const override {return true;}
28 };
29 
30 } // namespace Acl
31 
32 template <Http::HdrType header>
33 int
35 {
36  const auto checklist = Filled(ch);
37 
38  char const *theHeader = checklist->request->header.getStr(header);
39 
40  if (nullptr == theHeader)
41  return 0;
42 
43  return data->match(theHeader);
44 }
45 
46 #endif /* SQUID_SRC_ACL_REQUESTHEADERSTRATEGY_H */
47 
int match(ACLChecklist *) override
Matches the actual data in checklist against this Acl::Node.
matches the value of a given request header (e.g., "browser" or "referer_regex")
bool requiresRequest() const override
whether our (i.e. shallow) match() requires checklist to have a request
Definition: Acl.cc:33
ACLFilledChecklist * Filled(ACLChecklist *checklist)
convenience and safety wrapper for dynamic_cast<ACLFilledChecklist*>

 

Introduction

Documentation

Support

Miscellaneous