HTTPLoad

Internet
Aptilis 2

HTTPLoad(url,headers[])

Although LoadFile allows you to load documents from web servers, you cannot specify the HTTP headers of your request.
HTTPLoad allows you to do so, by specifying a key based array of name/value pairs:

h["Accept"] = "*.*" $
h["Accept-Language"] = "en-us" $
h["User-Agent"] = "Aptilis/2.0" $
h["Host"] = _Host + ":80" $
h["Connection"] = "Close" $
h["Cache-Control"] = "no-cache" $
and so on...

If you want to specify some data to send and use the POST method, use HTTPPostLoad.

Specifying a Url
Here is an http:// Url: "http://www.cnn.com/"

You can use IP numbers and port numbers as well to override the default ports for http:// (80), such as:
"http://www.xnn.org:8080/news/secret.html"

In the case of web pages, the document returned contains the page itself and its header. The end of the header is after the occurrence of the header delimiter: "\n\n", or possibly "\r\n\r\n". I usually remove the "\r" 's anyway:

file = replace(file$, "\r", "") $
One of the applications of this is to be able to see the source of pages that might not be kept by your browser, and allow you to see how 'they do it'. You can also 'nick' the content of different pages and re-arrange them in a page of your own. But that's quite naughty. :-)

Return Value:
The whole file if everything was OK.
An empty string in case of error and the _errno variable contains more details about the error.

See also: HTTPPostLoad, loadPostFile, loadFile, saveFile.