Squid Web Cache
master
Loading...
Searching...
No Matches
HeaderMangling.h
Go to the documentation of this file.
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
#ifndef SQUID_SRC_HEADERMANGLING_H
10
#define SQUID_SRC_HEADERMANGLING_H
11
12
#include "
acl/forward.h
"
13
#include "
format/Format.h
"
14
#include "
http/RegisteredHeaders.h
"
15
16
#include <functional>
17
#include <list>
18
#include <map>
19
#include <string>
20
#if HAVE_STRINGS_H
21
#include <strings.h>
22
#endif
23
24
class
HeaderWithAcl
;
25
class
HttpHeader
;
26
class
HttpHeaderEntry
;
27
class
StoreEntry
;
28
29
typedef
std::list<HeaderWithAcl>
HeaderWithAclList
;
30
31
/* Distinguish between Request and Reply (for header mangling) */
32
typedef
enum
{
33
ROR_REQUEST
,
34
ROR_REPLY
35
}
req_or_rep_t
;
36
37
// Currently a POD
38
class
headerMangler
39
{
40
public
:
41
acl_access
*
access_list
;
42
char
*
replacement
;
43
};
44
46
class
HeaderManglers
47
{
48
public
:
49
HeaderManglers
();
50
~HeaderManglers
();
51
53
const
headerMangler
*
find
(
const
HttpHeaderEntry
&e)
const
;
54
56
headerMangler
*
track
(
const
char
*name);
57
59
void
setReplacement
(
const
char
*name,
const
char
*replacementValue);
60
62
void
dumpAccess
(
StoreEntry
*entry,
const
char
*optionName)
const
;
64
void
dumpReplacement
(
StoreEntry
*entry,
const
char
*optionName)
const
;
65
66
private
:
69
class
NoCaseLessThan
70
{
71
public
:
72
bool
operator()
(
const
std::string &lhs,
const
std::string &rhs)
const
{
73
return
strcasecmp(lhs.c_str(), rhs.c_str()) < 0;
74
}
75
};
76
78
typedef
std::map<std::string, headerMangler, NoCaseLessThan>
ManglersByName
;
79
81
headerMangler
known
[
static_cast<
int
>
(
Http::HdrType::enumEnd_
)];
82
84
ManglersByName
custom
;
85
87
headerMangler
all
;
88
89
private
:
90
/* not implemented */
91
HeaderManglers
(
const
HeaderManglers
&);
92
HeaderManglers
&
operator =
(
const
HeaderManglers
&);
93
};
94
95
class
HeaderWithAcl
96
{
97
public
:
98
HeaderWithAcl
() :
aclList
(nullptr),
valueFormat
(nullptr),
fieldId
(
Http
::HdrType::BAD_HDR),
quoted
(false) {}
99
101
std::string
fieldName
;
102
104
std::string
fieldValue
;
105
107
ACLList
*
aclList
;
108
110
Format::Format
*
valueFormat
;
111
113
Http::HdrType
fieldId
;
114
116
bool
quoted
;
117
};
118
119
void
httpHdrMangleList
(
HttpHeader
*,
HttpRequest
*,
const
AccessLogEntryPointer
&al,
req_or_rep_t
req_or_rep);
120
121
#endif
/* SQUID_SRC_HEADERMANGLING_H */
Format.h
req_or_rep_t
req_or_rep_t
Definition
HeaderMangling.h:32
ROR_REPLY
@ ROR_REPLY
Definition
HeaderMangling.h:34
ROR_REQUEST
@ ROR_REQUEST
Definition
HeaderMangling.h:33
httpHdrMangleList
void httpHdrMangleList(HttpHeader *, HttpRequest *, const AccessLogEntryPointer &al, req_or_rep_t req_or_rep)
Definition
HeaderMangling.cc:82
HeaderWithAclList
std::list< HeaderWithAcl > HeaderWithAclList
Definition
HeaderMangling.h:29
RegisteredHeaders.h
forward.h
Format::Format
Definition
Format.h:42
HeaderManglers::NoCaseLessThan
Definition
HeaderMangling.h:70
HeaderManglers::NoCaseLessThan::operator()
bool operator()(const std::string &lhs, const std::string &rhs) const
Definition
HeaderMangling.h:72
HeaderManglers
A collection of headerMangler objects for a given message kind.
Definition
HeaderMangling.h:47
HeaderManglers::operator=
HeaderManglers & operator=(const HeaderManglers &)
HeaderManglers::dumpAccess
void dumpAccess(StoreEntry *entry, const char *optionName) const
report the *_header_access part of the configuration
Definition
HeaderMangling.cc:161
HeaderManglers::~HeaderManglers
~HeaderManglers()
Definition
HeaderMangling.cc:149
HeaderManglers::HeaderManglers
HeaderManglers(const HeaderManglers &)
HeaderManglers::find
const headerMangler * find(const HttpHeaderEntry &e) const
returns a header mangler for field e or nil if none was specified
Definition
HeaderMangling.cc:215
HeaderManglers::setReplacement
void setReplacement(const char *name, const char *replacementValue)
updates mangler for the named header with a replacement value
Definition
HeaderMangling.cc:204
HeaderManglers::custom
ManglersByName custom
one mangler for each custom header
Definition
HeaderMangling.h:84
HeaderManglers::ManglersByName
std::map< std::string, headerMangler, NoCaseLessThan > ManglersByName
a name:mangler map; optimize: use unordered map or some such
Definition
HeaderMangling.h:78
HeaderManglers::all
headerMangler all
configured if some mangling ACL applies to all header names
Definition
HeaderMangling.h:87
HeaderManglers::track
headerMangler * track(const char *name)
returns a mangler for the named header (known or custom)
Definition
HeaderMangling.cc:187
HeaderManglers::dumpReplacement
void dumpReplacement(StoreEntry *entry, const char *optionName) const
report the *_header_replace part of the configuration
Definition
HeaderMangling.cc:173
HeaderManglers::HeaderManglers
HeaderManglers()
Definition
HeaderMangling.cc:143
HeaderManglers::known
headerMangler known[static_cast< int >(Http::HdrType::enumEnd_)]
one mangler for each known header
Definition
HeaderMangling.h:81
HeaderWithAcl
Definition
HeaderMangling.h:96
HeaderWithAcl::aclList
ACLList * aclList
when the header field should be added (always if nil)
Definition
HeaderMangling.h:107
HeaderWithAcl::fieldId
Http::HdrType fieldId
internal ID for "known" headers or HDR_OTHER
Definition
HeaderMangling.h:113
HeaderWithAcl::quoted
bool quoted
whether fieldValue may contain macros
Definition
HeaderMangling.h:116
HeaderWithAcl::fieldName
std::string fieldName
HTTP header field name.
Definition
HeaderMangling.h:101
HeaderWithAcl::valueFormat
Format::Format * valueFormat
compiled HTTP header field value (no macros)
Definition
HeaderMangling.h:110
HeaderWithAcl::HeaderWithAcl
HeaderWithAcl()
Definition
HeaderMangling.h:98
HeaderWithAcl::fieldValue
std::string fieldValue
HTTP header field value, possibly with macros.
Definition
HeaderMangling.h:104
HttpHeaderEntry
Definition
HttpHeader.h:51
HttpHeader
Definition
HttpHeader.h:75
HttpRequest
Definition
HttpRequest.h:49
RefCount< Acl::Tree >
StoreEntry
Definition
Store.h:38
headerMangler
Definition
HeaderMangling.h:39
headerMangler::access_list
acl_access * access_list
Definition
HeaderMangling.h:41
headerMangler::replacement
char * replacement
Definition
HeaderMangling.h:42
Http
Definition
forward.h:18
Http::HdrType
HdrType
Definition
RegisteredHeaders.h:21
Http::enumEnd_
@ enumEnd_
Definition
RegisteredHeaders.h:122
squid
src
HeaderMangling.h
Generated by
1.9.8