/usr/share/tcltk/tcllib1.18/httpwget/wget.tcl is in tcllib 1.18-dfsg-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | ###
# Tool to download file from the web
# Enhacements to http
###
package provide http::wget 0.1
package require http
::namespace eval ::http {}
###
# topic: 1ed971e03ae89415e2f25d20e59b765c
# description: this proc contributed by Donal Fellows
###
proc ::http::_followRedirects {url args} {
while 1 {
set token [geturl $url -validate 1]
set ncode [ncode $token]
if { $ncode eq "404" } {
error "URL Not found"
}
switch -glob $ncode {
30[1237] {### redirect - see below ###}
default {cleanup $token ; return $url}
}
upvar #0 $token state
array set meta [set ${token}(meta)]
cleanup $token
if {![info exists meta(Location)]} {
return $url
}
set url $meta(Location)
unset meta
}
return $url
}
###
# topic: fced7bc395596569ac225a719c686dcc
###
proc ::http::wget {url destfile {verbose 1}} {
set tmpchan [open $destfile w]
fconfigure $tmpchan -translation binary
if { $verbose } {
puts [list GETTING [file tail $destfile] from $url]
}
set real_url [_followRedirects $url]
set token [geturl $real_url -channel $tmpchan -binary yes]
if {[ncode $token] != "200"} {
error "DOWNLOAD FAILED"
}
cleanup $token
close $tmpchan
}
|