The client component provides means to retrieve data over a network using several protocols. The protocols currently supported are HTTP and FILE. The client can be used to retrieve ASCII or binary based documents. It has both a Tcl and a C++ interface, enabling its use in both script and C++ programs.
The Tcl interface should be installed in the prelude of a session by calling the function init_client(tk) in <extern/client.h>
urlget <url> -- returns the body of the document pointed to
by <url>
urlget <url> <file> -- saves the body of the document pointed to
by <url> to <file>
urlget_tmp <url> -- returns the name of a temp file, containing the
body of the document pointed to by <url>
urlheader -- returns the header of the last document
urltype -- returns the type of the last document
The following script will show the possibilties of the client Tcl interface. It will retrieve the hush homepage a few times using several protocols.
#!netshell.out
# retrieve hush home page several times.
# use http and file protocol
urlget http://www.cs.vu.nl/~hush/
urlget file:/home/hush/www/index.html
set contents [urlget http://www.cs.vu.nl/~hush/]
puts \$contents
# save contents to /tmp/test
urlget http://www.cs.vu.nl/~hush/ /tmp/test
#save to a tmp file
set tmpfile [urlget_tmp http://www.cs.vu.nl/~hush/]
puts "Saved to: \$tmpfile"
# print info about transfer
puts "Header is: "
puts [urlheader]
puts "MIME type is: "
puts [urltype]
Not all MIME types are correctly recognized by the FILE protocol.
Send questions/bugs to bastiaan@cs.vu.nl
|
Hush Online Technology
hush@cs.vu.nl
09/24/99 |
|
|