You first must have called InetOpen.
Downloading a web page
To download a web page from a server, you can call InetConnectUrl. The first arg you pass is the URL of the web page. For example, if you want to download the REXX User's web page, you would specify "http://www.borg.com/~jglatt/rexx/rexxuser.htm". In other words, you specify it exactly as it would be typed into your browser's Address bar. The second arg is the name of some REXX variable that you wish to be set to a server handle that InetConnectUrl creates for you. You do not need to know the details of what a server handle is. The third arg is various options. We'll discuss some options later, but you can usually omit this arg to accept the default options. The fourth arg is a string containing any additional Http headers you may need to send to the server. If you have no such headers, you can omit this arg.
If InetConnectUrl succeeds, it will return an empty string, and the server handle will also be stored in your choice of variable. If it fails, it will either return an error message, or raise some condition, depending upon how you set the InetErr variable.
After successfully connecting to the server, you can download the webpage/file and put the contents of it into a REXX variable of your choice by calling InetIn. The first arg is the name of some REXX variable where you wish the data to be stored. The second arg can be omitted to download the entire webpage/file.
If InetIn succeeds, the contents of the webpage/file will be in our variable. If InetIn fails, it will return an error message, or raise some condition.
The last thing you need to do is call InetClose, passing it the handle you got from InetConnectUrl().
Here is an example of downloading a web page from www.microsoft.com. We assume that InetErr has been set to "ERROR".
DO /* "Open" the web page "http://www.microsoft.com", and put the * server handle in "MicrosoftHandle". */ InetConnectUrl("http://www.microsoft.com", "MicrosoftHandle") /* Download the webpage/file we "opened" with InetConnectUrl, and * place it into "contents". */ InetIn("contents") CATCH ERROR CONDITION("M") FINALLY /* Close the handle. */ InetClose("MicrosoftHandle") ENDNote: Downloading a web page does not also download all of the pages/files that are linked to it. If you need to do that, you'll have to process the contents of the page, looking for <A tags and parse out the linked file name after HREF= (and note the name is quoted), and then download each individual page/file.
There is one shortcut you can employ. If you use the "DOWNLOAD" option for InetConnectUrl, then RexxInet automatically calls InetIn on your behalf, and then InetClose. The variable name you then pass to InetConnectUrl is the name of the variable where you wish the contents of the webpage/file stored.
DO /* "Open" the web page "http://www.microsoft.com", and put the * contents in "contents". */ InetConnectUrl("http://www.microsoft.com", "contents", "DOWNLOAD") CATCH ERROR CONDITION("M") ENDNote: There is a default limit to the size of a resource that can be downloaded. To query, or change this setting, use InetMaxIn.
Uploading a web page
Ideally, if the server supports Ftp protocol, then it is much easier to upload your HTML and other files via Ftp protocol.