38 : aclList(nullptr), valueFormat(nullptr), theValue(aVal), theMethod(m)
52 if (al && valueFormat) {
55 valueFormat->assemble(mb, al, 0);
56 theFormattedValue.assign(mb.
content());
57 return theFormattedValue;
65 values.push_back(
new Value(value, quoted, descr, m));
77 for (
const auto &v:
values) {
79 const auto &ret = ch.
fastCheck(v->aclList);
80 debugs(93, 5,
"Check for header name: " <<
theKey <<
": " << v->value() <<
81 ", HttpRequest: " << request <<
" HttpReply: " << reply <<
" matched: " << ret);
83 matched = v->format(al);
94 for (
const auto &v:
values) {
95 const SBuf &formatted = v->format(al);
101 pairs->
add(
key(), formatted);
109 for (
const auto &v:
values) {
116 if (item.cmp(
"\n") == 0)
129 for (
const auto &v:
values) {
140 static const char *names[] = {
154 static Keys keys(std::begin(names), std::end(names));
160 formattedValues(allowFormatted)
162 if (extraReservedKeys)
178 for (
const auto &n:
notes)
179 if (n->key() == noteKey)
187 if (std::find(banned.begin(), banned.end(), key) != banned.end())
204 key[specialIndex] <<
"' within annotation name. " <<
205 "Future Squid versions will not support this.");
214 fatalf(
"FATAL: Missing note key");
220 fatalf(
"FATAL: Missing note value");
235 int keyLen = strlen(k);
243 " already exists and will be overwritten");
252 fatalf(
"FATAL: Missing annotation kv pair");
258 for (
const auto &n:
notes)
259 n->updateNotePairs(pairs, delimiters, al);
265 for (
const auto &n:
notes)
266 n->printAsNoteDirective(entry, directiveName);
272 const char *separator =
"";
273 for (
const auto ¬e:
notes) {
275 note->printAsAnnotationAclParameters(os);
286 if (!e->name().cmp(noteKey)) {
289 resultNote.
append(e->value());
300NotePairs::print(std::ostream &os,
const char *
const nameValueSeparator,
const char *
const entryTerminator)
const
303 os << e->name() << nameValueSeparator << e->value() << entryTerminator;
310 if (!e->name().cmp(noteKey))
311 return const_cast<SBuf &
>(e->value()).c_str();
330 Entries::iterator i =
entries.begin();
332 i = (*i)->name().cmp(key) ? i+1 :
entries.erase(i);
338 Entries::iterator i =
entries.begin();
340 i = (*i)->name() == key ?
entries.erase(i) : i+1;
347 const auto tokenCharacters = delimiters.
complement(
"non-delimiters");
350 (void)
tok.prefix(token, tokenCharacters);
352 }
while (
tok.skipOne(delimiters));
360 expandedEntries.clear();
361 for (
const auto &entry:
entries)
362 AppendTokens(expandedEntries, entry->name(), entry->value(), *delimiters);
363 return expandedEntries;
378 if (e->name() == key && e->value() == value)
386 for (
const auto &e: src->
entries)
393 for (
const auto &e: src->
entries) {
394 if (!
hasPair(e->name(), e->value()))
402 for (
const auto &e: src->
entries) {
403 if (std::find(appendables.begin(), appendables.end(), e->name()) == appendables.end())
412 for (
const auto &e: src->
entries)
#define Here()
source code location of the caller
static void AppendTokens(NotePairs::Entries &entries, const SBuf &key, const SBuf &val, const CharacterSet &delimiters)
String SBufToString(const SBuf &s)
size_t aclParseAclList(ConfigParser &, ACLList **config, const char *label)
Acl::Answer const & fastCheck()
void updateAle(const AccessLogEntry::Pointer &)
void updateReply(const HttpReply::Pointer &)
void syncAle(HttpRequest *adaptedRequest, const char *logUri) const override
assigns uninitialized adapted_request and url ALE components
SBufList treeDump(const char *name, ActionToStringConverter converter) const
optimized set of C chars, with quick membership test and merge support
CharacterSet complement(const char *complementLabel=nullptr) const
static const CharacterSet DIGIT
static const CharacterSet ALPHA
static void DisableMacros()
Do not allow macros inside quoted strings.
static char * NextQuotedToken()
static bool NextKvPair(char *&key, char *&value)
static bool LastTokenWasQuoted()
static char * NextToken()
static void EnableMacros()
Allow macros inside quoted strings.
static const char * QuoteString(const String &var)
char * content()
start of the added data
Used to store a note key/value pair.
void appendNewOnly(const NotePairs *src)
void append(const NotePairs *src)
Append the entries of the src NotePairs list to our list.
std::vector< SBuf > Names
std::vector< Entry::Pointer > Entries
The key/value pair entries.
std::optional< SBuf > find(const char *noteKey, const char *sep=",") const
void add(const SBuf &key, const SBuf &value)
void print(std::ostream &os, const char *nameValueSeparator, const char *entryTerminator) const
void remove(const char *key)
void replaceOrAdd(const NotePairs *src)
bool hasPair(const SBuf &key, const SBuf &value) const
const Entries & expandListEntries(const CharacterSet *delimiters) const
const char * findFirst(const char *noteKey) const
void addStrList(const SBuf &key, const SBuf &values, const CharacterSet &delimiters)
Entries entries
The key/value pair entries.
void replaceOrAddOrAppend(const NotePairs *src, const Names &appendables)
Stores a value for the note.
Format::Format * valueFormat
Compiled annotation value format.
ACLList * aclList
The access list used to determine if this value is valid for a request.
Value(const char *aVal, const bool quoted, const char *descr, const Method method=mhReplace)
const SBuf & format(const AccessLogEntryPointer &al)
Value::Pointer addValue(const char *value, const bool quoted, const char *descr, const Value::Method m=Value::mhAppend)
bool match(HttpRequest *request, HttpReply *reply, const AccessLogEntryPointer &al, SBuf &matched)
Values values
The possible values list for the note.
void printAsNoteDirective(StoreEntry *, const char *directiveName) const
Prints key and value(s) using a "note" directive format (including directive name).
void printAsAnnotationAclParameters(std::ostream &) const
void updateNotePairs(NotePairsPointer pairs, const CharacterSet *delimiters, const AccessLogEntryPointer &al)
Note::Pointer find(const SBuf ¬eKey)
Note::Pointer parse(ConfigParser &parser)
Parses a notes line and returns a pointer to the parsed Note object.
std::vector< SBuf > Keys
unordered annotation names
Note::Pointer add(const SBuf ¬eKey)
void updateNotePairs(NotePairsPointer pairs, const CharacterSet *delimiters, const AccessLogEntryPointer &al)
const char * descr
identifies note source in error messages
void printAsNoteDirectives(StoreEntry *, const char *directiveName) const
Prints notes using "note" squid.conf directive format, one directive per stored note.
void banReservedKey(const SBuf &key, const Keys &banned) const
Makes sure the given key is not on the given list of banned names.
NotesList notes
The Note::Pointer objects array list.
bool formattedValues
whether to expand quoted logformat codes
static const Notes::Keys & ReservedKeys()
always prohibited key names
void printAsAnnotationAclParameters(std::ostream &) const
void validateKey(const SBuf &key) const
void parseKvPair()
Parses an annotate line with "key=value" or "key+=value" formats.
Keys reservedKeys
a list of additional prohibited key names
void push_back(char)
Append a single character. The character may be NUL (\0).
static const size_type npos
size_type findFirstNotOf(const CharacterSet &set, size_type startPos=0) const
SBuf & append(const SBuf &S)
an std::runtime_error with thrower location info
#define debugs(SECTION, LEVEL, CONTENT)
void fatalf(const char *fmt,...)
void aclDestroyAclList(ACLList **list)
const char * AllowOrDeny(const Answer &action)
SBuf ToSBuf(Args &&... args)
slowly stream-prints all arguments into a freshly allocated SBuf