28 other_.init(4*1024, 1*1024*1024);
30 if (other_.potentialSpaceSize() <
static_cast<mb_size_t>(len))
33 other_.append(buf, len);
40 debugs(84, 3,
"Parsing helper buffer");
42 if (!other_.hasContent()) {
46 debugs(84, 3,
"Zero length reply");
50 char *p = other_.content();
51 size_t len = other_.contentSize();
58 debugs(84, 3,
"Buff length is larger than 2");
61 if (!strncmp(p,
"OK",2) && (len == 2 || p[2] ==
' ')) {
62 debugs(84, 3,
"helper Result = OK");
65 }
else if (!strncmp(p,
"ERR",3) && (len == 3 || p[3] ==
' ')) {
66 debugs(84, 3,
"helper Result = ERR");
69 }
else if (!strncmp(p,
"BH",2) && (len == 2 || p[2] ==
' ')) {
70 debugs(84, 3,
"helper Result = BH");
73 }
else if (!strncmp(p,
"TT ",3)) {
80 const char *authToken = w1;
81 notes.add(
"token",authToken);
85 notes.add(
"message",
"Missing 'token' data");
88 }
else if (!strncmp(p,
"AF ",3)) {
99 const char *authToken = w1;
100 notes.add(
"token",authToken);
102 const char *user = w2;
103 notes.add(
"user",user);
105 }
else if (w1 !=
nullptr) {
107 const char *user = w1;
108 notes.add(
"user",user);
110 }
else if (!strncmp(p,
"NA ",3)) {
120 other_.consume(p - other_.content());
121 other_.consumeWhitespacePrefix();
129 notes.add(
"message", other_.content());
138 if (c >=
'a' && c <=
'z')
141 if (c >=
'A' && c <=
'Z')
144 if (c >=
'0' && c <=
'9')
147 if (c ==
'-' || c ==
'_')
159 static const std::vector<SBuf> recognized = {
160 SBuf(
"clt_conn_tag"),
182 key <<
'=' << value <<
183 Debug::Extra <<
"advice: Name or remove this annotation");
197 if (std::find(recognized.begin(), recognized.end(), key) != recognized.end())
200 debugs(84,
DBG_IMPORTANT,
"WARNING: Unsupported or unexpected from-helper annotation with a name reserved for Squid use: " <<
201 key <<
'=' << value <<
202 Debug::Extra <<
"advice: If this is a custom annotation, rename it to add a trailing underscore: " <<
210 while (other_.hasContent()) {
211 char *p = other_.content();
226 const bool urlDecode = (*p !=
'"');
228 if (v !=
nullptr && urlDecode && (p-v) > 2)
232 const SBuf parsedKey(key);
233 const SBuf parsedValue(v);
234 CheckReceivedKey(parsedKey, parsedValue);
235 notes.add(parsedKey, parsedValue);
237 other_.consume(p - other_.content());
238 other_.consumeWhitespacePrefix();
285 os <<
", other: \"" << o.
content() <<
'\"';
static bool isKeyNameChar(char c)
restrict key names to alphanumeric, hyphen, underscore characters
char * strwordtok(char *buf, char **t)
static std::ostream & Extra(std::ostream &os)
prefixes each grouped debugs() line after the first one in the group
const MemBuf & emptyBuf() const
Return an empty MemBuf.
Helper::ResultCode result
The helper response 'result' field.
Reply()
Creates a NULL reply.
const MemBuf & other() const
static void CheckReceivedKey(const SBuf &, const SBuf &)
warns admin about problematic key=value pairs
bool accumulate(const char *buf, size_t len)
void init(mb_size_t szInit, mb_size_t szMax)
char * content()
start of the added data
const char * toString(const char *sep="\r\n") const
const_reverse_iterator rbegin() const
#define debugs(SECTION, LEVEL, CONTENT)
helper protocol primitives
std::ostream & operator<<(std::ostream &, const Reply &)
void rfc1738_unescape(char *url)