]> git.ipfire.org Git - thirdparty/squid.git/blob - src/acl/MethodData.cc
Merged from trunk
[thirdparty/squid.git] / src / acl / MethodData.cc
1 /*
2 * Copyright (C) 1996-2015 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 "cache_cf.h"
15 #include "http/RequestMethod.h"
16
17 int ACLMethodData::ThePurgeCount = 0;
18
19 ACLMethodData::ACLMethodData(ACLMethodData const &old)
20 {
21 assert(old.values.empty());
22 }
23
24 ACLMethodData::~ACLMethodData()
25 {
26 values.clear();
27 }
28
29 bool
30 ACLMethodData::match(HttpRequestMethod toFind)
31 {
32 for (auto i = values.begin(); i != values.end(); ++i) {
33 if (*i == toFind) {
34 // tune the list for LRU ordering
35 values.erase(i);
36 values.push_front(toFind);
37 return true;
38 }
39 }
40 return false;
41 }
42
43 SBufList
44 ACLMethodData::dump() const
45 {
46 SBufList sl;
47 for (std::list<HttpRequestMethod>::const_iterator i = values.begin(); i != values.end(); ++i) {
48 sl.push_back((*i).image());
49 }
50
51 return sl;
52 }
53
54 void
55 ACLMethodData::parse()
56 {
57 while (char *t = strtokFile()) {
58 HttpRequestMethod m;
59 m.HttpRequestMethodXXX(t);
60 values.push_back(m);
61 if (values.back() == Http::METHOD_PURGE)
62 ++ThePurgeCount; // configuration code wants to know
63 }
64 }
65
66 ACLData<HttpRequestMethod> *
67 ACLMethodData::clone() const
68 {
69 assert(values.empty());
70 return new ACLMethodData(*this);
71 }
72