# HG changeset patch # User Matti Hamalainen # Date 1613755791 -7200 # Node ID 4b985abf5ababd5a65cca437954fb93188fa048a # Parent 10ea2c1101b3618ad3d745d9f590ac0f200ed212 fetch_feeds: Move HTTP initialization to end of script. diff -r 10ea2c1101b3 -r 4b985abf5aba fetch_feeds.tcl --- a/fetch_feeds.tcl Wed Feb 17 12:10:14 2021 +0200 +++ b/fetch_feeds.tcl Fri Feb 19 19:29:51 2021 +0200 @@ -24,27 +24,20 @@ ############################################################################## - package require sqlite3 package require http -if {[info exists http_user_agent] && $http_user_agent != ""} { - ::http::config -urlencoding utf8 -useragent $http_user_agent -} else { - ::http::config -urlencoding utf8 -useragent "Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Firefox/38.0" + +############################################################################## +### Utility functions + +proc fetch_sanitize_encoding {uencoding} { + regsub -- "^\[a-z\]\[a-z\]_\[A-Z\]\[A-Z\]\." $uencoding "" uencoding + set uencoding [string tolower $uencoding] + regsub -- "^iso-" $uencoding "iso" uencoding + return $uencoding } -if {[info exists http_use_proxy] && $http_use_proxy != 0} { - ::http::config -proxyhost $http_proxy_host -proxyport $http_proxy_port -} - -if {[info exists http_tls_support] && $http_tls_support != 0} { - package require tls - ::http::register https 443 [list ::tls::socket -request true -require true -ssl2 false -ssl3 false -tls1 true -tls1.1 true -tls1.2 true -cadir $http_tls_cadir -autoservername true] -} - - -############################################################################## proc fetch_dorequest { urlStr urlStatus urlSCode urlCode urlData urlMeta } { upvar $urlStatus ustatus @@ -212,7 +205,26 @@ +############################################################################## ### Open database, etc +############################################################################## +if {[info exists http_user_agent] && $http_user_agent != ""} { + ::http::config -urlencoding utf8 -useragent $http_user_agent +} else { + ::http::config -urlencoding utf8 -useragent "Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Firefox/38.0" +} + +if {[info exists http_use_proxy] && $http_use_proxy != 0} { + ::http::config -proxyhost $http_proxy_host -proxyport $http_proxy_port +} + +if {[info exists http_tls_support] && $http_tls_support != 0} { + package require tls + ::http::register https 443 [list ::tls::socket -request true -require true -ssl2 false -ssl3 false -tls1 true -tls1.1 true -tls1.2 true -cadir $http_tls_cadir -autoservername true] +} + + + set nitems 0 set currclock [clock seconds] global feeds_db