]> git.ipfire.org Git - thirdparty/squid.git/blame - src/acl/RequestHeaderStrategy.h
Maintenance: automate header guards 2/3 (#1655)
[thirdparty/squid.git] / src / acl / RequestHeaderStrategy.h
CommitLineData
5dee515e 1/*
b8ae064d 2 * Copyright (C) 1996-2023 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
ff9d9458
FC
9#ifndef SQUID_SRC_ACL_REQUESTHEADERSTRATEGY_H
10#define SQUID_SRC_ACL_REQUESTHEADERSTRATEGY_H
8319d478 11
127dce76 12#include "acl/Data.h"
602d9612 13#include "acl/FilledChecklist.h"
8319d478 14#include "acl/ParameterizedNode.h"
a2ac85d9 15#include "HttpRequest.h"
5dee515e 16
8319d478 17namespace Acl
5dee515e 18{
62e76326 19
8319d478
AR
20/// matches the value of a given request header (e.g., "browser" or "referer_regex")
21template <Http::HdrType header>
22class RequestHeaderCheck: public ParameterizedNode< ACLData<const char *> >
23{
62e76326 24public:
922513e5 25 /* Acl::Node API */
8319d478 26 int match(ACLChecklist *) override;
337b9aa4 27 bool requiresRequest() const override {return true;}
5dee515e 28};
29
8319d478
AR
30} // namespace Acl
31
789217a2 32template <Http::HdrType header>
5dee515e 33int
8319d478 34Acl::RequestHeaderCheck<header>::match(ACLChecklist * const ch)
5dee515e 35{
8319d478
AR
36 const auto checklist = Filled(ch);
37
a9925b40 38 char const *theHeader = checklist->request->header.getStr(header);
62e76326 39
aee3523a 40 if (nullptr == theHeader)
62e76326 41 return 0;
42
5dee515e 43 return data->match(theHeader);
44}
45
ff9d9458 46#endif /* SQUID_SRC_ACL_REQUESTHEADERSTRATEGY_H */
f53969cc 47