Version 3 of http::geturl

Updated 2009-11-12 13:17:10 by arjen

Part of the http package.

Reference page information found at [L1 ]

[Add information concerning what this particular method does]

AM (12 november 2009) The method itself gets the entire URL page and returns a token that can be used for subsequent inspections. The option -channel is meant to put the data that come back into an opened file (or channel). However, in my experience, it adds some information at the start and at the end. This makes it unusable for retrieving binary files.

Here is a short fragment of how to retrieve a zip file (my use case):

set token [::http::geturl $URL]
set outfile [open myzipfile.zip w]
fconfigure $outfile -translation binary 
puts -nonewline $outfile [::http::data $token]
close $outfile

(My first attempt looked like this:

set outfile [open myzipfile.zip w]
fconfigure $outfile -translation binary 
::http::geturl $URL -channel $outfile
close $outfile

but this gives a corrupted zip-file that can not be read using the vfs::zip package - other unzip programs may deal with it correctly though)