29 other_.init(4*1024, 1*1024*1024);
31 if (other_.potentialSpaceSize() <
static_cast<mb_size_t>(len))
34 other_.append(buf, len);
41 debugs(84, 3,
"Parsing helper buffer");
43 if (!other_.hasContent()) {
47 debugs(84, 3,
"Zero length reply");
51 char *p = other_.content();
52 size_t len = other_.contentSize();
59 debugs(84, 3,
"Buff length is larger than 2");
62 if (!strncmp(p,
"OK",2) && (len == 2 || p[2] ==
' ')) {
63 debugs(84, 3,
"helper Result = OK");
66 }
else if (!strncmp(p,
"ERR",3) && (len == 3 || p[3] ==
' ')) {
67 debugs(84, 3,
"helper Result = ERR");
70 }
else if (!strncmp(p,
"BH",2) && (len == 2 || p[2] ==
' ')) {
71 debugs(84, 3,
"helper Result = BH");
74 }
else if (!strncmp(p,
"TT ",3)) {
81 const char *authToken = w1;
82 notes.add(
"token",authToken);
86 notes.add(
"message",
"Missing 'token' data");
89 }
else if (!strncmp(p,
"AF ",3)) {
100 const char *authToken = w1;
101 notes.add(
"token",authToken);
103 const char *user = w2;
104 notes.add(
"user",user);
106 }
else if (w1 !=
nullptr) {
108 const char *user = w1;
109 notes.add(
"user",user);
111 }
else if (!strncmp(p,
"NA ",3)) {
121 other_.consume(p - other_.content());
122 other_.consumeWhitespacePrefix();
130 notes.add(
"message", other_.content());
139 if (c >=
'a' && c <=
'z')
142 if (c >=
'A' && c <=
'Z')
145 if (c >=
'0' && c <=
'9')
148 if (c ==
'-' || c ==
'_')
160 static const std::vector<SBuf> recognized = {
161 SBuf(
"clt_conn_tag"),
183 key <<
'=' << value <<
184 Debug::Extra <<
"advice: Name or remove this annotation");
198 if (std::find(recognized.begin(), recognized.end(), key) != recognized.end())
201 debugs(84,
Important(69),
"WARNING: Unsupported or unexpected from-helper annotation with a name reserved for Squid use: " <<
202 key <<
'=' << value <<
203 Debug::Extra <<
"advice: If this is a custom annotation, rename it to add a trailing underscore: " <<
211 while (other_.hasContent()) {
212 char *p = other_.content();
227 const bool urlDecode = (*p !=
'"');
229 if (v !=
nullptr && urlDecode && (p-v) > 2)
233 const SBuf parsedKey(key);
234 const SBuf parsedValue(v);
235 CheckReceivedKey(parsedKey, parsedValue);
236 notes.add(parsedKey, parsedValue);
238 other_.consume(p - other_.content());
239 other_.consumeWhitespacePrefix();
286 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 &)
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)