]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/acl/HttpHeaderData.cc
2 * Copyright (C) 1996-2014 The Squid Software Foundation and contributors
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.
9 /* DEBUG: section 28 Access Control */
13 #include "acl/Checklist.h"
14 #include "acl/HttpHeaderData.h"
15 #include "acl/RegexData.h"
17 #include "ConfigParser.h"
19 #include "HttpHeaderTools.h"
22 /* Construct an ACLHTTPHeaderData that uses an ACLRegex rule with the value of the
23 * selected header from a given request.
25 * TODO: This can be generalised by making the type of the regex_rule into a
26 * template parameter - so that we can use different rules types in future.
28 ACLHTTPHeaderData::ACLHTTPHeaderData() : hdrId(HDR_BAD_HDR
), regex_rule(new ACLRegexData
)
31 ACLHTTPHeaderData::~ACLHTTPHeaderData()
37 ACLHTTPHeaderData::match(HttpHeader
* hdr
)
42 debugs(28, 3, "aclHeaderData::match: checking '" << hdrName
<< "'");
45 if (hdrId
!= HDR_BAD_HDR
) {
48 value
= hdr
->getStrOrList(hdrId
);
50 if (!hdr
->getByNameIfPresent(hdrName
.termedBuf(), value
))
55 return regex_rule
->match(cvalue
.c_str());
59 ACLHTTPHeaderData::dump() const
62 sl
.push_back(SBuf(hdrName
));
63 // temp is needed until c++11 move-constructor
64 SBufList temp
= regex_rule
->dump();
65 sl
.splice(sl
.end(), temp
);
70 ACLHTTPHeaderData::parse()
72 char* t
= strtokFile();
75 hdrId
= httpHeaderIdByNameDef(hdrName
.rawBuf(), hdrName
.size());
80 ACLHTTPHeaderData::empty() const
82 return (hdrId
== HDR_BAD_HDR
&& hdrName
.size()==0) || regex_rule
->empty();
85 ACLData
<HttpHeader
*> *
86 ACLHTTPHeaderData::clone() const
88 /* Header's don't clone yet. */
89 ACLHTTPHeaderData
* result
= new ACLHTTPHeaderData
;
90 result
->regex_rule
= regex_rule
->clone();
91 result
->hdrId
= hdrId
;
92 result
->hdrName
= hdrName
;