]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/HttpHeaderTools.h
1 #ifndef SQUID_HTTPHEADERTOOLS_H
2 #define SQUID_HTTPHEADERTOOLS_H
4 #include "format/Format.h"
5 #include "HttpHeader.h"
22 class HttpHeaderFieldInfo
;
27 typedef std::list
<HeaderWithAcl
> HeaderWithAclList
;
33 acl_access
*access_list
;
37 /// A collection of headerMangler objects for a given message kind.
44 /// returns a header mangler for field e or nil if none was specified
45 const headerMangler
*find(const HttpHeaderEntry
&e
) const;
47 /// returns a mangler for the named header (known or custom)
48 headerMangler
*track(const char *name
);
50 /// updates mangler for the named header with a replacement value
51 void setReplacement(const char *name
, const char *replacementValue
);
53 /// report the *_header_access part of the configuration
54 void dumpAccess(StoreEntry
*entry
, const char *optionName
) const;
55 /// report the *_header_replace part of the configuration
56 void dumpReplacement(StoreEntry
*entry
, const char *optionName
) const;
59 /// a name:mangler map; optimize: use unordered map or some such
60 typedef std::map
<std::string
, headerMangler
> ManglersByName
;
62 /// one mangler for each known header
63 headerMangler known
[HDR_ENUM_END
];
65 /// one mangler for each custom header
66 ManglersByName custom
;
68 /// configured if some mangling ACL applies to all header names
73 HeaderManglers(const HeaderManglers
&);
74 HeaderManglers
&operator =(const HeaderManglers
&);
80 HeaderWithAcl() : aclList(NULL
), fieldId (HDR_BAD_HDR
), quoted(false) {}
82 /// HTTP header field name
83 std::string fieldName
;
85 /// HTTP header field value, possibly with macros
86 std::string fieldValue
;
88 /// when the header field should be added (always if nil)
91 /// compiled HTTP header field value (no macros)
92 Format::Format
*valueFormat
;
94 /// internal ID for "known" headers or HDR_OTHER
95 http_hdr_type fieldId
;
97 /// whether fieldValue may contain macros
101 int httpHeaderParseOffset(const char *start
, int64_t * off
);
103 HttpHeaderFieldInfo
*httpHeaderBuildFieldsInfo(const HttpHeaderFieldAttrs
* attrs
, int count
);
104 void httpHeaderDestroyFieldsInfo(HttpHeaderFieldInfo
* info
, int count
);
105 http_hdr_type
httpHeaderIdByName(const char *name
, size_t name_len
, const HttpHeaderFieldInfo
* attrs
, int end
);
106 http_hdr_type
httpHeaderIdByNameDef(const char *name
, int name_len
);
107 const char *httpHeaderNameById(int id
);
108 int httpHeaderHasConnDir(const HttpHeader
* hdr
, const char *directive
);
109 int httpHeaderParseInt(const char *start
, int *val
);
110 void httpHeaderPutStrf(HttpHeader
* hdr
, http_hdr_type id
, const char *fmt
,...) PRINTF_FORMAT_ARG3
;
112 const char *getStringPrefix(const char *str
, const char *end
);
114 void httpHdrMangleList(HttpHeader
*, HttpRequest
*, int req_or_rep
);