#!/bin/sh
# Beispiel für das http Package
# \
exec tclsh $0 $@

package require http

set url http://tcl.activestate.com

#set url http://127.0.0.1:631

# Metainformation
set token [http::geturl $url -validate 1 ]
foreach {name value} [set $token\(meta)] {
  puts stderr [format "%-20s = %-20s" $name  $value]
}


# File
set fd [open as.html w]
puts stderr "Hole $url"

proc progress {handle max size } {
  puts -nonewline stderr  [format " %.0f%% " [expr 100.0*$size/$max]]
}

set token [::http::geturl $url  \
 -channel $fd \
 -blocksize 2048 \
 -progress progress
]

puts stderr "fertig"
puts stderr [http::code $token]
http::cleanup $token
close $fd
exit