]>
Commit | Line | Data |
---|---|---|
3b07476b CT |
1 | #ifndef SQUID_HTTPHEADERTOOLS_H |
2 | #define SQUID_HTTPHEADERTOOLS_H | |
3 | ||
f4698e0b | 4 | #include "format/Format.h" |
582c2af2 | 5 | #include "HttpHeader.h" |
fc54b8d2 | 6 | #include "typedefs.h" |
f4698e0b CT |
7 | |
8 | #if HAVE_LIST | |
9 | #include <list> | |
10 | #endif | |
3b07476b CT |
11 | #if HAVE_MAP |
12 | #include <map> | |
13 | #endif | |
14 | #if HAVE_STRING | |
15 | #include <string> | |
16 | #endif | |
17 | ||
f4698e0b CT |
18 | class HeaderWithAcl; |
19 | typedef std::list<HeaderWithAcl> HeaderWithAclList; | |
20 | ||
3b07476b CT |
21 | class acl_access; |
22 | struct _header_mangler { | |
23 | acl_access *access_list; | |
24 | char *replacement; | |
25 | }; | |
26 | typedef struct _header_mangler header_mangler; | |
27 | ||
28 | class StoreEntry; | |
29 | ||
30 | /// A collection of header_mangler objects for a given message kind. | |
d3abcb0d A |
31 | class HeaderManglers |
32 | { | |
3b07476b CT |
33 | public: |
34 | HeaderManglers(); | |
35 | ~HeaderManglers(); | |
36 | ||
37 | /// returns a header mangler for field e or nil if none was specified | |
38 | const header_mangler *find(const HttpHeaderEntry &e) const; | |
39 | ||
40 | /// returns a mangler for the named header (known or custom) | |
41 | header_mangler *track(const char *name); | |
42 | ||
43 | /// updates mangler for the named header with a replacement value | |
44 | void setReplacement(const char *name, const char *replacementValue); | |
45 | ||
46 | /// report the *_header_access part of the configuration | |
47 | void dumpAccess(StoreEntry *entry, const char *optionName) const; | |
48 | /// report the *_header_replace part of the configuration | |
49 | void dumpReplacement(StoreEntry *entry, const char *optionName) const; | |
50 | ||
51 | private: | |
52 | /// a name:mangler map; optimize: use unordered map or some such | |
53 | typedef std::map<std::string, header_mangler> ManglersByName; | |
54 | ||
55 | /// one mangler for each known header | |
56 | header_mangler known[HDR_ENUM_END]; | |
57 | ||
58 | /// one mangler for each custom header | |
59 | ManglersByName custom; | |
60 | ||
61 | /// configured if some mangling ACL applies to all header names | |
62 | header_mangler all; | |
63 | ||
64 | private: | |
65 | /* not implemented */ | |
66 | HeaderManglers(const HeaderManglers &); | |
67 | HeaderManglers &operator =(const HeaderManglers &); | |
68 | }; | |
f4698e0b CT |
69 | |
70 | class ACLList; | |
71 | class HeaderWithAcl | |
72 | { | |
73 | public: | |
74 | HeaderWithAcl() : aclList(NULL), fieldId (HDR_BAD_HDR), quoted(false) {} | |
75 | ||
76 | /// HTTP header field name | |
77 | std::string fieldName; | |
78 | ||
79 | /// HTTP header field value, possibly with macros | |
80 | std::string fieldValue; | |
81 | ||
82 | /// when the header field should be added (always if nil) | |
83 | ACLList *aclList; | |
84 | ||
85 | /// compiled HTTP header field value (no macros) | |
86 | Format::Format *valueFormat; | |
87 | ||
88 | /// internal ID for "known" headers or HDR_OTHER | |
89 | http_hdr_type fieldId; | |
90 | ||
91 | /// whether fieldValue may contain macros | |
92 | bool quoted; | |
93 | }; | |
582c2af2 | 94 | |
fc54b8d2 FC |
95 | extern int httpHeaderParseOffset(const char *start, int64_t * off); |
96 | ||
97 | class HttpHeaderFieldInfo; | |
98 | class String; | |
99 | ||
100 | extern HttpHeaderFieldInfo *httpHeaderBuildFieldsInfo(const HttpHeaderFieldAttrs * attrs, int count); | |
101 | extern void httpHeaderDestroyFieldsInfo(HttpHeaderFieldInfo * info, int count); | |
102 | extern http_hdr_type httpHeaderIdByName(const char *name, size_t name_len, const HttpHeaderFieldInfo * attrs, int end); | |
103 | extern http_hdr_type httpHeaderIdByNameDef(const char *name, int name_len); | |
104 | extern const char *httpHeaderNameById(int id); | |
105 | extern int httpHeaderHasConnDir(const HttpHeader * hdr, const char *directive); | |
106 | extern int httpHeaderParseInt(const char *start, int *val); | |
107 | extern void httpHeaderPutStrf(HttpHeader * hdr, http_hdr_type id, const char *fmt,...) PRINTF_FORMAT_ARG3; | |
108 | ||
1dff8715 FC |
109 | extern const char *getStringPrefix(const char *str, const char *end); |
110 | ||
3b07476b | 111 | #endif |