]> git.ipfire.org Git - thirdparty/squid.git/blame - src/acl/MethodData.cc
SourceFormat Enforcement
[thirdparty/squid.git] / src / acl / MethodData.cc
CommitLineData
48071869 1/*
bbc27441 2 * Copyright (C) 1996-2014 The Squid Software Foundation and contributors
48071869 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.
48071869 7 */
8
bbc27441
AJ
9/* DEBUG: section 28 Access Control */
10
582c2af2 11#include "squid.h"
3ad63615 12#include "acl/Checklist.h"
602d9612 13#include "acl/MethodData.h"
06390e4b 14#include "cache_cf.h"
d477ce03 15#include "http/RequestMethod.h"
48071869 16
5491c11e
AR
17int ACLMethodData::ThePurgeCount = 0;
18
cd44274b 19ACLMethodData::ACLMethodData(ACLMethodData const &old)
48071869 20{
cd44274b 21 assert(old.values.empty());
48071869 22}
23
24ACLMethodData::~ACLMethodData()
25{
cd44274b 26 values.clear();
48071869 27}
28
29bool
60745f24 30ACLMethodData::match(HttpRequestMethod toFind)
48071869 31{
c70b36bd 32 for (auto i = values.begin(); i != values.end(); ++i) {
cd44274b
AJ
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;
48071869 41}
42
9b859d6f 43SBufList
4f8ca96e 44ACLMethodData::dump() const
48071869 45{
9b859d6f 46 SBufList sl;
cd44274b
AJ
47 for (std::list<HttpRequestMethod>::const_iterator i = values.begin(); i != values.end(); ++i) {
48 sl.push_back((*i).image());
48071869 49 }
50
9b859d6f 51 return sl;
48071869 52}
53
54void
55ACLMethodData::parse()
56{
cd44274b 57 while (char *t = strtokFile()) {
f9688132
AJ
58 HttpRequestMethod m;
59 m.HttpRequestMethodXXX(t);
cd44274b
AJ
60 values.push_back(m);
61 if (values.back() == Http::METHOD_PURGE)
d73e600f 62 ++ThePurgeCount; // configuration code wants to know
48071869 63 }
64}
65
60745f24 66ACLData<HttpRequestMethod> *
48071869 67ACLMethodData::clone() const
68{
cd44274b 69 assert(values.empty());
48071869 70 return new ACLMethodData(*this);
71}
f53969cc 72