]> git.ipfire.org Git - thirdparty/squid.git/blob - src/acl/MethodData.cc
19db2a68fd0a2dbc08e9188da48225692ea94651
[thirdparty/squid.git] / src / acl / MethodData.cc
1 /*
2 * Copyright (C) 1996-2025 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 /* DEBUG: section 28 Access Control */
10
11 #include "squid.h"
12 #include "acl/Checklist.h"
13 #include "acl/MethodData.h"
14 #include "ConfigParser.h"
15 #include "http/RequestMethod.h"
16
17 int ACLMethodData::ThePurgeCount = 0;
18
19 ACLMethodData::~ACLMethodData()
20 {
21 values.clear();
22 }
23
24 bool
25 ACLMethodData::match(HttpRequestMethod toFind)
26 {
27 for (auto i = values.begin(); i != values.end(); ++i) {
28 if (*i == toFind) {
29 // tune the list for LRU ordering
30 values.erase(i);
31 values.push_front(toFind);
32 return true;
33 }
34 }
35 return false;
36 }
37
38 SBufList
39 ACLMethodData::dump() const
40 {
41 SBufList sl;
42 for (std::list<HttpRequestMethod>::const_iterator i = values.begin(); i != values.end(); ++i) {
43 sl.push_back((*i).image());
44 }
45
46 return sl;
47 }
48
49 void
50 ACLMethodData::parse()
51 {
52 while (char *t = ConfigParser::strtokFile()) {
53 HttpRequestMethod m;
54 m.HttpRequestMethodXXX(t);
55 values.push_back(m);
56 if (values.back() == Http::METHOD_PURGE)
57 ++ThePurgeCount; // configuration code wants to know
58 }
59 }
60