Go to the documentation of this file.
31 other_.init(4*1024, 1*1024*1024);
33 if (other_.potentialSpaceSize() <
static_cast<mb_size_t>(len))
36 other_.append(buf, len);
43 debugs(84, 3,
"Parsing helper buffer");
45 if (!other_.hasContent()) {
49 debugs(84, 3,
"Zero length reply");
53 char *p = other_.content();
54 size_t len = other_.contentSize();
61 debugs(84, 3,
"Buff length is larger than 2");
64 if (!strncmp(p,
"OK",2) && (len == 2 || p[2] ==
' ')) {
65 debugs(84, 3,
"helper Result = OK");
68 }
else if (!strncmp(p,
"ERR",3) && (len == 3 || p[3] ==
' ')) {
69 debugs(84, 3,
"helper Result = ERR");
72 }
else if (!strncmp(p,
"BH",2) && (len == 2 || p[2] ==
' ')) {
73 debugs(84, 3,
"helper Result = BH");
76 }
else if (!strncmp(p,
"TT ",3)) {
83 const char *authToken = w1;
84 notes.add(
"token",authToken);
88 notes.add(
"message",
"Missing 'token' data");
91 }
else if (!strncmp(p,
"AF ",3)) {
102 const char *authToken = w1;
103 notes.add(
"token",authToken);
105 const char *user = w2;
106 notes.add(
"user",user);
108 }
else if (w1 !=
nullptr) {
110 const char *user = w1;
111 notes.add(
"user",user);
113 }
else if (!strncmp(p,
"NA ",3)) {
123 other_.consume(p - other_.content());
124 other_.consumeWhitespacePrefix();
132 notes.add(
"message", other_.content());
141 if (c >=
'a' && c <=
'z')
144 if (c >=
'A' && c <=
'Z')
147 if (c >=
'0' && c <=
'9')
150 if (c ==
'-' || c ==
'_')
162 static const std::vector<SBuf> recognized = {
163 SBuf(
"clt_conn_tag"),
185 key <<
'=' << value <<
186 Debug::Extra <<
"advice: Name or remove this annotation");
200 if (std::find(recognized.begin(), recognized.end(), key) != recognized.end())
203 debugs(84,
Important(69),
"WARNING: Unsupported or unexpected from-helper annotation with a name reserved for Squid use: " <<
204 key <<
'=' << value <<
205 Debug::Extra <<
"advice: If this is a custom annotation, rename it to add a trailing underscore: " <<
213 while (other_.hasContent()) {
214 char *p = other_.content();
229 const bool urlDecode = (*p !=
'"');
231 if (v !=
nullptr && urlDecode && (p-v) > 2)
235 const SBuf parsedKey(key);
236 const SBuf parsedValue(v);
237 CheckReceivedKey(parsedKey, parsedValue);
238 notes.add(parsedKey, parsedValue);
240 other_.consume(p - other_.content());
241 other_.consumeWhitespacePrefix();
292 os <<
", other: \"" << o.
content() <<
'\"';
Reply()
Creates a NULL reply.
static bool isKeyNameChar(char c)
restrict key names to alphanumeric, hyphen, underscore characters
const_reverse_iterator rbegin() const
static void CheckReceivedKey(const SBuf &, const SBuf &)
warns admin about problematic key=value pairs
const MemBuf & emptyBuf() const
Return an empty MemBuf.
void print(std::ostream &os, const char *nameValueSeparator, const char *entryTerminator) const
void init(mb_size_t szInit, mb_size_t szMax)
std::ostream & operator<<(std::ostream &, const Reply &)
const MemBuf & other() const
void rfc1738_unescape(char *url)
bool accumulate(const char *buf, size_t len)
Helper::ResultCode result
The helper response 'result' field.
char * strwordtok(char *buf, char **t)
helper protocol primitives
static std::ostream & Extra(std::ostream &)
char * content()
start of the added data
#define debugs(SECTION, LEVEL, CONTENT)