Also useful for the future ALE-using context-reporting code that must be
silent regarding unknowns, including unknown request methods.
SBuf
AccessLogEntry::getLogMethod() const
{
+ static const SBuf dash("-");
SBuf method;
if (icp.opcode)
method.append(icp_opcode_str[icp.opcode]);
else if (htcp.opcode)
method.append(htcp.opcode);
- else
+ else if (http.method)
method = http.method.image();
+ else
+ method = dash;
return method;
}
/// Fetch the external ACL provided 'user=' string, or nil if none is available.
const char *getExtUser() const;
+ /// whether we know what the request method is
+ bool hasLogMethod() const { return icp.opcode || htcp.opcode || http.method; }
+
/// Fetch the transaction method string (ICP opcode, HTCP opcode or HTTP method)
SBuf getLogMethod() const;
break;
case LFT_REQUEST_METHOD:
- sb = al->getLogMethod();
- out = sb.c_str();
- quote = 1;
+ if (al->hasLogMethod()) {
+ sb = al->getLogMethod();
+ out = sb.c_str();
+ quote = 1;
+ }
break;
case LFT_REQUEST_URI:
return *this;
}
+ /// whether the method is set/known
+ explicit operator bool() const { return theMethod != Http::METHOD_NONE; }
+
bool operator == (Http::MethodType const & aMethod) const { return theMethod == aMethod; }
bool operator == (HttpRequestMethod const & aMethod) const {
return theMethod == aMethod.theMethod &&