diff options
author | dkf <donal.k.fellows@manchester.ac.uk> | 2014-03-05 22:28:12 (GMT) |
---|---|---|
committer | dkf <donal.k.fellows@manchester.ac.uk> | 2014-03-05 22:28:12 (GMT) |
commit | 666e80e5bd56c2edbfb3560924cdf2a73170e485 (patch) | |
tree | 68e5f6785b4207bdd3dde4afb032a29f351b21b7 /library/http | |
parent | 9597c478f9a01087b8969f960e14adf9df328eeb (diff) | |
download | tcl-666e80e5bd56c2edbfb3560924cdf2a73170e485.zip tcl-666e80e5bd56c2edbfb3560924cdf2a73170e485.tar.gz tcl-666e80e5bd56c2edbfb3560924cdf2a73170e485.tar.bz2 |
more checks of domain data loading
Diffstat (limited to 'library/http')
-rw-r--r-- | library/http/cookiejar.tcl | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/library/http/cookiejar.tcl b/library/http/cookiejar.tcl index 5c25e28..a4ee78a 100644 --- a/library/http/cookiejar.tcl +++ b/library/http/cookiejar.tcl @@ -25,7 +25,7 @@ namespace eval ::http { # TODO: is this the _right_ list of domains to use? Or is there an alias # for it that will persist longer? variable cookiejar_domainlist \ - http://mxr.mozilla.org/mozilla-central/source/netwerk/dns/effective_tld_names.dat?raw=1 + http://publicsuffix.org/list/effective_tld_names.dat variable cookiejar_domainfile \ [file join [file dirname [info script]] effective_tld_names.txt.gz] # The list is directed to from http://publicsuffix.org/list/ @@ -142,7 +142,7 @@ package provide cookiejar $::http::cookiejar_version return $loglevel } - variable aid deletions + variable purgeTimer deletions constructor {{path ""}} { namespace import ::http::cookiejar_support::* namespace upvar ::http cookiejar_purgeinterval purgeinterval @@ -194,6 +194,7 @@ package provide cookiejar $::http::cookiejar_version CREATE INDEX sessionLookup ON sessionCookies (domain, path); --;# View to allow for simple looking up of a cookie. + --;# Deletion policy: NOT SUPPORTED via this view. CREATE TEMP VIEW cookies AS SELECT id, domain, path, key, value, originonly, secure, 1 AS persistent @@ -225,7 +226,7 @@ package provide cookiejar $::http::cookiejar_version } log info "%s with %s entries" $storeorigin $cookieCount - set aid [after $purgeinterval [namespace current]::my PurgeCookies] + my PostponePurge # TODO: domain list refresh policy if {$path ne "" && ![db exists { @@ -235,6 +236,12 @@ package provide cookiejar $::http::cookiejar_version } } + method PostponePurge {} { + namespace upvar ::http cookiejar_purgeinterval interval + catch {after cancel $purgeTimer} + set purgeTimer [after $interval [namespace code {my PurgeCookies}]] + } + method GetDomainListOnline {} { upvar 0 ::http::cookiejar_domainlist url log debug "loading domain list from %s" $url @@ -345,7 +352,7 @@ package provide cookiejar $::http::cookiejar_version } } set n [expr {[db total_changes] - $n}] - log debug "processed %d inserts generated from domain list" $n + log info "constructed domain info with %d entries" $n } # This forces the rebuild of the domain data, loading it from @@ -361,7 +368,7 @@ package provide cookiejar $::http::cookiejar_version destructor { catch { - after cancel $aid + after cancel $purgeTimer } catch { db close @@ -525,8 +532,7 @@ package provide cookiejar $::http::cookiejar_version namespace upvar ::http \ cookiejar_vacuumtrigger trigger \ cookiejar_purgeinterval interval - catch {after cancel $aid} - set aid [after $interval [namespace current]::my PurgeCookies] + my PostponePurge set now [clock seconds] log debug "purging cookies that expired before %s" [clock format $now] db transaction { @@ -534,9 +540,9 @@ package provide cookiejar $::http::cookiejar_version DELETE FROM persistentCookies WHERE expiry < $now } incr deletions [db changes] + ### TODO: Cap the total number of cookies and session cookies, + ### purging least frequently used } - ### TODO: Cap the total number of cookies and session cookies, - ### purging least frequently used # Once we've deleted a fair bit, vacuum the database. Must be done # outside a transaction. |