Command: httpget

Syntax

httpget <url> {,<file> | <dir> }

Description

Downloads (fetches) a file across the internet. This command is also available under the name download. It effectively performs an HTTP GET operation.

A successful URL retrieval will set the system numeric found to 1. An error will set it to 0.

Note: If the web-server from which the download is being made has authorization checks involving the completion of a web-page, e.g. a login page, then this will not be processed like a browser. Such cases will have the effect of merely downloading the login page, instead of the requested file.

Parameters

Switches

Examples

Download a file index.htm into the local directory. Time out after 10 seconds wait.

httpget 'http://remotenode/index.htm',-tim=10

Download into the local directory and record the http header.

string header[] ;# Not strictly necessary
httpget 'http://remotenode/index.htm', -os=header

Download into a specified directory.

mkdir /tmp/cache
httpget 'http://remotenode/index.htm', /tmp/cache

Download into a specified file, i.e. download and rename.

httpget 'http://remotenode/yourfile.dat', /tmp/cache/myfile.dat

Download and expand a zip archive into a specified directory.

mkdir /tmp/cache/images
httpget 'http://remotenode/images.zip', c:/tmp/cache/images

Download a whole set of image files, and print confirmation.

cd c:/HolidaySnaps
for i=1,50 {
    httpget //snaps.com/holiday/^(i).jpg
    tell '^(i).jpg downloaded'
}

Download an image file asynchronously, and display it when it arrives.

atable myatab
procedure ~myatab.myproc = {
   args id=string,status=numeric,url=string
   if (status)
      tell <'Download of ',url,'failed. Status',status>
   else
      wdisplay id
}
string dest='abc.jpg'
httpget 'http://www.bogus.com/imageserver/getimage?name=abc',dest,-cb=~myatab.myproc,-id=dest,-to=30
#  do other stuff while waiting ...

See Also

Commands:

httppost, httpset

Identifiers

http_code (numeric), http_max_connections (numeric)