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"
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
24class HeaderWithAcl;
25class HttpHeader;
26class HttpHeaderEntry;
27class StoreEntry;
28
29typedef std::list<HeaderWithAcl> HeaderWithAclList;
30
31/* Distinguish between Request and Reply (for header mangling) */
36
37// Currently a POD
39{
40public:
43};
44
47{
48public:
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
66private:
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
82
85
88
89private:
90 /* not implemented */
93};
94
96{
97public:
98 HeaderWithAcl() : aclList(nullptr), valueFormat(nullptr), fieldId(Http::HdrType::BAD_HDR), quoted(false) {}
99
101 std::string fieldName;
102
104 std::string fieldValue;
105
108
111
114
116 bool quoted;
117};
118
120
121#endif /* SQUID_SRC_HEADERMANGLING_H */
req_or_rep_t
@ ROR_REPLY
@ ROR_REQUEST
void httpHdrMangleList(HttpHeader *, HttpRequest *, const AccessLogEntryPointer &al, req_or_rep_t req_or_rep)
std::list< HeaderWithAcl > HeaderWithAclList
bool operator()(const std::string &lhs, const std::string &rhs) const
A collection of headerMangler objects for a given message kind.
HeaderManglers & operator=(const HeaderManglers &)
void dumpAccess(StoreEntry *entry, const char *optionName) const
report the *_header_access part of the configuration
HeaderManglers(const HeaderManglers &)
const headerMangler * find(const HttpHeaderEntry &e) const
returns a header mangler for field e or nil if none was specified
void setReplacement(const char *name, const char *replacementValue)
updates mangler for the named header with a replacement value
ManglersByName custom
one mangler for each custom header
std::map< std::string, headerMangler, NoCaseLessThan > ManglersByName
a name:mangler map; optimize: use unordered map or some such
headerMangler all
configured if some mangling ACL applies to all header names
headerMangler * track(const char *name)
returns a mangler for the named header (known or custom)
void dumpReplacement(StoreEntry *entry, const char *optionName) const
report the *_header_replace part of the configuration
headerMangler known[static_cast< int >(Http::HdrType::enumEnd_)]
one mangler for each known header
ACLList * aclList
when the header field should be added (always if nil)
Http::HdrType fieldId
internal ID for "known" headers or HDR_OTHER
bool quoted
whether fieldValue may contain macros
std::string fieldName
HTTP header field name.
Format::Format * valueFormat
compiled HTTP header field value (no macros)
std::string fieldValue
HTTP header field value, possibly with macros.
acl_access * access_list
Definition forward.h:18