Posted to tcl by aspect at Tue Oct 28 13:31:56 GMT 2014view raw
- package require http
- package require tls
- http::register https 443 ::tls::socket
- http::config -useragent poop
- # -- simple wrapper for http::geturl
- proc geturl {url} {
- puts "Trying $url ..."
- set tok [::http::geturl $url]
- try {
- upvar 1 $tok state
- if {[set status [::http::status $tok]] ne "ok"} {
- error $status
- }
- if {[dict exists [::http::meta $tok] Location]} {
- tailcall geturl [dict get [::http::meta $tok] Location]
- }
- return [::http::data $tok]
- } finally {
- ::http::cleanup $tok
- }
- }
- set tar [geturl http://sourceforge.net/projects/tcl/files/Tcl/8.6.3/tk8.6.3rc1-src.tar.gz/download]
- puts [string length $tar]
- return
- ## output:
- Trying http://sourceforge.net/projects/tcl/files/Tcl/8.6.3/tk8.6.3rc1-src.tar.gz ...
- Trying http://sourceforge.net/projects/tcl/files/Tcl/8.6.3/tk8.6.3rc1-src.tar.gz/download ...
- Trying http://downloads.sourceforge.net/project/tcl/Tcl/8.6.3/tk8.6.3rc1-src.tar.gz?r=&ts=1414503080&use_mirror=aarnet ...
- Trying http://aarnet.dl.sourceforge.net/project/tcl/Tcl/8.6.3/tk8.6.3rc1-src.tar.gz ...
- 4257787