I/O - HTTP
I have created a few files on helpin.red server to make tests with HTTP I/O:
http://helpin.red/samples/samplescript1.txt - a simple loop without Red's header ( repeat i 3 [prin "hello " print i] ).
http://helpin.red/samples/samplescript2.txt - a simple loop with Red's header. ( Red[] repeat i 3 [prin "hello " print i] )
http://helpin.red/samples/samplehtml1.html - a sample html page
>> print read http://helpin.red/samples/samplescript1.txt
repeat i 3 [prin "hello " print i]
>> print read http://helpin.red/samples/samplescript2.txt
Red[] repeat i 3 [prin "hello " print i]
From a red script or using the console, you may execute code from a remote server:
>> do read http://helpin.red/samples/samplescript1.txt ;without header
hello 1
hello 2
hello 3
If the code in the remote server has the Red header, you may execute it directly, without the read statement:
>> do http://helpin.red/samples/samplescript2.txt ;with Red [] header
hello 1
hello 2
hello 3
You may load data or code, including functions and objects:
>> a: load http://helpin.red/samples/samplescript1.txt
== [repeat i 3 [prin "hello " print i]]
>> do a
hello 1
hello 2
hello 3
HTML files may also be accessed for processing. Take a look at the example using the parse dialect.
>> print read http://helpin.red/samples/samplehtml1.html
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="content-type">
<title>testHtmlPage</title>
</head>
<body>
...
</html>
Rebolek's red-tools has some HTTP tools that you may find interesting.
To be continued...