REBOL 3 Docs | Guide | Concepts | Functions | Datatypes | Errors |
TOC < Back Next > | Updated: 6-Feb-2009 Edit History |
URL is an acronym for Uniform Resource Locator, an Internet standard used to access resources such as web pages, images, files, and email across the network. The best known URL scheme is that used for web locations such as http://www.REBOL.com.
URL values are a subset of series, and thus can be manipulated as series:
url: http://www.rebol.com/reboldoc.html
probe to-file find/reverse (tail url) "rebol"
%reboldoc.html
The first part of a URL indicates its communications protocol, called a scheme. The language supports several schemes, including: web pages ('HTTP:), file transfer ('FTP:), newsgroups ('NNTP:), email ('MAILTO:), files ('FILE:), finger ('FINGER:), whois ('WHOIS:), small network time ('DAYTIME:), post office ('POP:), transmission control ('TCP:) and domain name service ('DNS:). These scheme names are followed by characters that are dependent on which scheme being used.
http://host.dom/path/file ftp://host.dom/path/file nntp://news.some-isp.net/some.news.group mailto:name@domain file://host/path/file finger://user@host.dom whois://rebol@rs.internic.net daytime://everest.cclabs.missouri.edu pop://user:passwd@host.dom/ tcp://host.dom:21 dns://host.dom
Some fields are optional. For instance, the host can be followed by a port number if it differs from the default. An FTP URL supplies a default password if one is not specified:
ftp://user:password@host.dom/path/file
Characters in a URL must conform to Internet standards. Restricted characters must be encoded in hexadecimal by preceding them with the escape character %:
probe http://www.somesite.dom/odd%28dir%29/odd%7Bfile%7D.txt
http://www.somesite.dom/odd%28dir%29/odd%7Bfile%7D.txt
print http://www.somesite.dom/odd%28dir%29/odd%7Bfile%7D.txt
http://www.somesite.dom/odd(dir)/odd{file}.txt
The to-url function converts blocks to the url! datatype, the first element in the block is the scheme, the second element is the domain (with or without user:pass and port) the remaining elements are the path and file:
probe to-url [http www.rebol.com reboldoc.html]
http://www.rebol.com/reboldoc.html
probe to-url [http www.rebol.com %examples "websend.r"]
http://www.rebol.com/examples/websend.r
probe to-url [http usr:pass@host.com:80 "(path)" %index.html]
http://usr:pass@host.com:80/%28path%29/index.html
The datatype word is url!.
Use url? to test the datatype.
probe url? ftp://ftp.rebol.com/
true
As urls are a subset of the series pseudotype, use series? to check this:
probe series? http://www.rebol.com/
true
TOC < Back Next > | REBOL.com - WIP Wiki | Feedback Admin |