On Thu, 26 Feb 2004, OTR Comm wrote:

> I am using squid-3.0 so I looked in errorpage.cc and found the
> errorConvert(char token, ErrorState * err) function.

Yes, this is where it all happens.

> I see how the URL is setup in the case for 'U'.
> I see that
> HttpRequest *r = err->request;

The important part of %U is found further down

case 'U':
p = r ? urlCanonicalClean(r) : err->url ? err->url : "[no URL]";

this calculates what %U should be replaced by. Translated to english the
above logics is

If there is a request then use the URL from the request
else if there is a URL registered in the ErrorState object use that url
else "[no URL]".

> Now, can I setup another case in errorConvert for the username (maybe
> 'C' for client ID) and reference 'r->extacl_user' to get the username?

extacl_user is maybe not what you are looking for. This is the username as
returned by external_acl_type, not the username from authentication.

There is quite many kinds of usernames in Squid. The current Squid-3.0
sources have the following different username concepts:

* Username from URL, as in ftp://userassword@host/

* Username from authentication

* Username from IDENT lookup

* Username from external acl lookup (external_acl_type)

* Username from SSL certificate

As each have somewhat different meaning each is accessed differently.

Examples on how most of these can be accessed can be found in
ClientHttpRequest::logRequest() and clientPrepareLogWithRequestDetails()
(both found in client_side.cc) where the information is prepared for
logging in access.log.