log_ip.toStr(buf, bufsz);
}
+SBuf
+AccessLogEntry::getLogMethod() const
+{
+ SBuf method;
+ if (icp.opcode)
+ method.append(icp_opcode_str[icp.opcode]);
+ else if (htcp.opcode)
+ method.append(htcp.opcode);
+ else
+ method = http.method.image();
+ return method;
+}
+
AccessLogEntry::~AccessLogEntry()
{
safe_free(headers.request);
/// including indirect forwarded-for IP if configured to log that
void getLogClientIp(char *buf, size_t bufsz) const;
+ /// Fetch the transaction method string (ICP opcode, HTCP opcode or HTTP method)
+ SBuf getLogMethod() const;
+
const char *url;
/// TCP/IP level details about the client connection
} adapt;
#endif
- // Why is this a sub-class and not a set of real "private:" fields?
- // TODO: shuffle this to the relevant ICP/HTCP protocol section
- class Private
- {
-
- public:
- Private() : method_str(NULL) {}
-
- const char *method_str;
- } _private;
-
const char *lastAclName; ///< string for external_acl_type %ACL format code
const char *lastAclData; ///< string for external_acl_type %DATA format code
break;
case LFT_REQUEST_METHOD:
- if (al->_private.method_str) // ICP, HTCP method code
- out = al->_private.method_str;
- else {
- const SBuf &s = al->http.method.image();
+ {
+ const SBuf s(al->getLogMethod());
sb.append(s.rawContent(), s.length());
out = sb.termedBuf();
quote = 1;
char clientip[MAX_IPSTRLEN];
al->getLogClientIp(clientip, MAX_IPSTRLEN);
- static SBuf method;
- if (al->_private.method_str)
- method.assign(al->_private.method_str);
- else
- method = al->http.method.image();
+ const SBuf method(al->getLogMethod());
logfilePrintf(logfile, "%s %s %s [%s] \"" SQUIDSBUFPH " %s %s/%d.%d\" %d %" PRId64 " \"%s\" \"%s\" %s:%s%s",
clientip,
char clientip[MAX_IPSTRLEN];
al->getLogClientIp(clientip, MAX_IPSTRLEN);
- static SBuf method;
- if (al->_private.method_str)
- method.assign(al->_private.method_str);
- else
- method = al->http.method.image();
+ const SBuf method(al->getLogMethod());
logfilePrintf(logfile, "%s %s %s [%s] \"" SQUIDSBUFPH " %s %s/%d.%d\" %d %" PRId64 " %s:%s%s",
clientip,
char clientip[MAX_IPSTRLEN];
al->getLogClientIp(clientip, MAX_IPSTRLEN);
- static SBuf method;
- if (al->_private.method_str)
- method.assign(al->_private.method_str);
- else
- method = al->http.method.image();
+ const SBuf method(al->getLogMethod());
logfilePrintf(logfile, "%9ld.%03d %6ld %s %s/%03d %" PRId64 " " SQUIDSBUFPH " %s %s %s%s/%s %s%s",
(long int) current_time.tv_sec,
if (!al->http.content_type || *al->http.content_type == '\0')
al->http.content_type = dash_str;
- if (al->icp.opcode)
- al->_private.method_str = icp_opcode_str[al->icp.opcode];
- else if (al->htcp.opcode)
- al->_private.method_str = al->htcp.opcode;
- else
- al->_private.method_str = NULL;
-
if (al->hier.host[0] == '\0')
xstrncpy(al->hier.host, dash_str, SQUIDHOSTNAMELEN);