]> git.ipfire.org Git - thirdparty/squid.git/blob - src/HttpHeaderTools.h
Removed squid-old.h
[thirdparty/squid.git] / src / HttpHeaderTools.h
1 #ifndef SQUID_HTTPHEADERTOOLS_H
2 #define SQUID_HTTPHEADERTOOLS_H
3
4 #include "format/Format.h"
5 #include "HttpHeader.h"
6
7 #if HAVE_LIST
8 #include <list>
9 #endif
10 #if HAVE_MAP
11 #include <map>
12 #endif
13 #if HAVE_STRING
14 #include <string>
15 #endif
16
17 class HeaderWithAcl;
18 typedef std::list<HeaderWithAcl> HeaderWithAclList;
19
20 class acl_access;
21 struct _header_mangler {
22 acl_access *access_list;
23 char *replacement;
24 };
25 typedef struct _header_mangler header_mangler;
26
27 class StoreEntry;
28
29 /// A collection of header_mangler objects for a given message kind.
30 class HeaderManglers
31 {
32 public:
33 HeaderManglers();
34 ~HeaderManglers();
35
36 /// returns a header mangler for field e or nil if none was specified
37 const header_mangler *find(const HttpHeaderEntry &e) const;
38
39 /// returns a mangler for the named header (known or custom)
40 header_mangler *track(const char *name);
41
42 /// updates mangler for the named header with a replacement value
43 void setReplacement(const char *name, const char *replacementValue);
44
45 /// report the *_header_access part of the configuration
46 void dumpAccess(StoreEntry *entry, const char *optionName) const;
47 /// report the *_header_replace part of the configuration
48 void dumpReplacement(StoreEntry *entry, const char *optionName) const;
49
50 private:
51 /// a name:mangler map; optimize: use unordered map or some such
52 typedef std::map<std::string, header_mangler> ManglersByName;
53
54 /// one mangler for each known header
55 header_mangler known[HDR_ENUM_END];
56
57 /// one mangler for each custom header
58 ManglersByName custom;
59
60 /// configured if some mangling ACL applies to all header names
61 header_mangler all;
62
63 private:
64 /* not implemented */
65 HeaderManglers(const HeaderManglers &);
66 HeaderManglers &operator =(const HeaderManglers &);
67 };
68
69 class ACLList;
70 class HeaderWithAcl
71 {
72 public:
73 HeaderWithAcl() : aclList(NULL), fieldId (HDR_BAD_HDR), quoted(false) {}
74
75 /// HTTP header field name
76 std::string fieldName;
77
78 /// HTTP header field value, possibly with macros
79 std::string fieldValue;
80
81 /// when the header field should be added (always if nil)
82 ACLList *aclList;
83
84 /// compiled HTTP header field value (no macros)
85 Format::Format *valueFormat;
86
87 /// internal ID for "known" headers or HDR_OTHER
88 http_hdr_type fieldId;
89
90 /// whether fieldValue may contain macros
91 bool quoted;
92 };
93
94 SQUIDCEXTERN int httpHeaderParseOffset(const char *start, int64_t * off);
95
96 #endif