There is not any need to store notes added using Note cfg option and notes added
from helper to separated member. This patch merge them to the same
AccessLogEntry::note member.
This is a Measurement Factory project
HttpRequest *request; //< virgin HTTP request
HttpRequest *adapted_request; //< HTTP request after adaptation and redirection
- // TODO: merge configNotes and helperNotes
- /// key:value pairs set by note.
- NotePairs::Pointer configNotes;
+ /// key:value pairs set by squid.conf note directive and
/// key=value pairs returned from URL rewrite/redirect helper
- NotePairs::Pointer helperNotes;
+ NotePairs::Pointer notes;
#if ICAP_CLIENT
/** \brief This subclass holds log info for ICAP part of request
#endif
HttpRequest::HttpRequest() :
- HttpMsg(hoRequest),
- helperNotes(NULL)
+ HttpMsg(hoRequest)
{
init();
}
HttpRequest::HttpRequest(const HttpRequestMethod& aMethod, AnyP::ProtocolType aProtocol, const char *aUrlpath) :
- HttpMsg(hoRequest),
- helperNotes(NULL)
+ HttpMsg(hoRequest)
{
static unsigned int id = 1;
debugs(93,7, HERE << "constructed, this=" << this << " id=" << ++id);
myportname.clean();
- helperNotes = NULL;
+ notes = NULL;
tag.clean();
#if USE_AUTH
// XXX: what to do with copy->peer_domain?
copy->myportname = myportname;
- copy->helperNotes = helperNotes;
copy->tag = tag;
#if USE_AUTH
copy->extacl_user = extacl_user;
// main property is which connection the request was received on (if any)
clientConnectionManager = aReq->clientConnectionManager;
+ notes = aReq->notes;
return true;
}
String myportname; // Internal tag name= value from port this requests arrived in.
- NotePairs::Pointer helperNotes; ///< collection of meta notes associated with this request by helper lookups.
+ NotePairs::Pointer notes; ///< annotations added by the note directive and helpers
String tag; /* Internal tag for this request */
#include "squid.h"
#include "globals.h"
+#include "AccessLogEntry.h"
#include "acl/FilledChecklist.h"
#include "acl/Gadgets.h"
#include "ConfigParser.h"
entries.push_back(new NotePairs::Entry((*i)->name.termedBuf(), (*i)->value.termedBuf()));
}
}
+
+
+NotePairs &
+SyncNotes(AccessLogEntry &ale, HttpRequest &request)
+{
+ if (!ale.notes) {
+ assert(!request.notes);
+ ale.notes = request.notes = new NotePairs;
+ } else {
+ assert(ale.notes == request.notes);
+ }
+ return *ale.notes;
+}
MEMPROXY_CLASS_INLINE(NotePairs::Entry);
+class AccessLogEntry;
+/**
+ * Keep in sync HttpRequest and the corresponding AccessLogEntry objects
+ */
+NotePairs &SyncNotes(AccessLogEntry &ale, HttpRequest &request);
+
#endif
#endif
- /*Add meta headers*/
+ /*Add notes*/
+ // The al->notes and request->notes must point to the same object.
+ // Enable the following assertion to check for possible bugs.
+ // assert(request->notes == al->notes);
typedef Notes::iterator ACAMLI;
for (ACAMLI i = Config.notes.begin(); i != Config.notes.end(); ++i) {
if (const char *value = (*i)->match(request, al->reply)) {
- if (al->configNotes == NULL)
- al->configNotes = new NotePairs;
- al->configNotes->add((*i)->key.termedBuf(), value);
+ NotePairs ¬es = SyncNotes(*al, *request);
+ notes.add((*i)->key.termedBuf(), value);
debugs(33, 3, HERE << (*i)->key.termedBuf() << " " << value);
}
}
// Put helper response Notes into the transaction state record (ALE) eventually
// do it early to ensure that no matter what the outcome the notes are present.
if (http->al != NULL) {
- if (!http->al->helperNotes)
- http->al->helperNotes = new NotePairs;
- http->al->helperNotes->append(&reply.notes);
- old_request->helperNotes = http->al->helperNotes;
+ NotePairs ¬es = SyncNotes(*http->al, *old_request);
+ notes.append(&reply.notes);
}
switch (reply.result) {
// Put helper response Notes into the transaction state record (ALE) eventually
// do it early to ensure that no matter what the outcome the notes are present.
if (http->al != NULL) {
- if (!http->al->helperNotes)
- http->al->helperNotes = new NotePairs;
- http->al->helperNotes->append(&reply.notes);
- old_request->helperNotes = http->al->helperNotes;
+ NotePairs ¬es = SyncNotes(*http->al, *old_request);
+ notes.append(&reply.notes);
}
switch (reply.result) {
sb.append(meta);
}
#endif
- if (al->helperNotes != NULL) {
- if (const char *note = al->helperNotes->find(fmt->data.string)) {
- if (sb.size())
- sb.append(", ");
- sb.append(note);
- }
- }
- if (al->configNotes != NULL) {
- if (const char *note = al->configNotes->find(fmt->data.string)) {
+ if (al->notes != NULL) {
+ if (const char *note = al->notes->find(fmt->data.string)) {
if (sb.size())
sb.append(", ");
sb.append(note);
if (ah != NULL && ah->metaHeaders != NULL && !ah->metaHeaders->empty())
sb.append(ah->metaHeaders->toString());
#endif
- if (al->helperNotes != NULL && !al->helperNotes->empty())
- sb.append(al->helperNotes->toString());
- if (al->configNotes != NULL && !al->configNotes->empty())
- sb.append(al->configNotes->toString());
+ if (al->notes != NULL && !al->notes->empty())
+ sb.append(al->notes->toString());
+
out = sb.termedBuf();
quote = 1;
}