Monday, November 08, 2010 at 12:06 AM.
system.verbs.builtins.webserver.postFilters.domainStats
on domainStats (pta) {
<<Keep track of the number of hits per domain, and number of seconds spent processing hits, by domain, and number of bytes served, by domain.
<<11/05/1999 at 7:29:59 PM by AR
if webserver.getPref ("flDomainStats") {
local (host = "default");
if defined (pta^.requestHeaders.["Host"]) {
local (hostName = pta^.requestHeaders.["Host"]);
if defined (config.mainResponder.domains.[hostName]) {
host = hostName}
else {
if hostName contains ":" {
hostName = string.popSuffix (hostName, ":")}; //remove trailing port
hostName = string.popTrailing (hostName, '.'); //remove trailing dot
if defined (config.mainResponder.domains.[hostName]) {
host = hostName}}};
local (adrStats = @user.webserver.stats.domains);
if not defined (adrStats^) {
new (tableType, adrStats)};
local (adrHost = @adrStats^.[host]);
if not defined (adrHost^) {
new (tableType, adrHost)};
local (ticks = clock.ticks () - pta^.stats.requestProcessingStarted);
if not defined (adrHost^.ticks) {
adrHost^.ticks = 0};
adrHost^.ticks = adrHost^.ticks + ticks;
if not defined (adrHost^.hits) {
adrHost^.hits = 0};
adrHost^.hits++;
if not defined (adrHost^.bytes) {
adrHost^.bytes = 0};
if defined (pta^.responseBody) {
adrHost^.bytes = adrHost^.bytes + string.length (pta^.responseBody)}};
return (true)}
This listing is for code that runs in the OPML Editor environment. I created these listings because I wanted the search engines to index it, so that when I want to look up something in my codebase I don't have to use the much slower search functionality in my object database. Dave Winer.