ParseURL - Maple Help

Sockets

 ParseURL
 parse a URL into its components

 Calling Sequence ParseURL(url)

Parameters

 url - string; URL to be parsed

Description

 • The procedure ParseURL is used to break a URL into its component parts. The argument url is a Maple string which represents the URL that is to be parsed.
 • If the URL can be parsed successfully, then a record describing the URL is returned.
 The record used to describe the URL has the following slots:

 scheme hostname port path user passwd

 • Not all components have meaning for all supported URL schema. The meaning of the resource path, in particular, is subject to interpretation according to the URL scheme. Scheme-specific interpretation of resource paths is not currently provided for in this procedure.
 • When a component is either meaningless, or not present and has no default value, then the corresponding slot has the value NULL. An empty string distinguishes an empty (zero length) slot value from one that is absent entirely in the URL. (For example, telnet://joe:@host.com/path/ versus telnet://joe@host.com/path/)
 • The URL parser is based on the specification for URLs given in RFC 1738 Uniform Recourse Locators (URL). All the registered URL schema from that specification are supported. URLs whose scheme is unregistered have the following generic syntax:

 ://:@:/

Examples

 > $\mathrm{with}\left(\mathrm{Sockets}\right):$
 > $\mathrm{url}≔\mathrm{ParseURL}\left("http://www.maplesoft.com/applications/"\right)$
 ${\mathrm{url}}{≔}{\mathrm{Record}}{}\left({\mathrm{scheme}}{=}{"http"}{,}{\mathrm{hostname}}{=}{"www.maplesoft.com"}{,}{\mathrm{port}}{=}{80}{,}{\mathrm{path}}{=}{"applications/"}{,}{\mathrm{user}}{=}\left(\right){,}{\mathrm{passwd}}{=}\left(\right)\right)$ (1)
 > $\mathrm{url}:-\mathrm{scheme},\mathrm{url}:-\mathrm{hostname},\mathrm{url}:-\mathrm{port},\mathrm{url}:-\mathrm{path}$
 ${"http"}{,}{"www.maplesoft.com"}{,}{80}{,}{"applications/"}$ (2)
 > $\mathrm{url}≔\mathrm{ParseURL}\left("ftp://user:passwd@host.com:2002/path/to/file.txt"\right):$
 > $\mathrm{url}:-\mathrm{scheme},\mathrm{url}:-\mathrm{hostname},\mathrm{url}:-\mathrm{port},\mathrm{url}:-\mathrm{path},\mathrm{url}:-\mathrm{user},\mathrm{url}:-\mathrm{passwd}$
 ${"ftp"}{,}{"host.com"}{,}{2002}{,}{"path/to/file.txt"}{,}{"user"}{,}{"passwd"}$ (3)
 > $\mathrm{url}≔\mathrm{ParseURL}\left("telnet://www.maplesoft.com:80"\right):$
 > $\mathrm{url}:-\mathrm{scheme},\mathrm{url}:-\mathrm{hostname},\mathrm{url}:-\mathrm{port},\mathrm{url}:-\mathrm{path}$
 ${"telnet"}{,}{"www.maplesoft.com"}{,}{80}$ (4)
 > $\mathrm{url}≔\mathrm{ParseURL}\left("unknownScheme://user:passwd@host.com:2002/some/resource?with=search"\right):$
 > $\mathrm{url}:-\mathrm{scheme},\mathrm{url}:-\mathrm{hostname},\mathrm{url}:-\mathrm{port},\mathrm{url}:-\mathrm{path},\mathrm{url}:-\mathrm{user},\mathrm{url}:-\mathrm{passwd}$
 ${"unknownscheme"}{,}{"host.com"}{,}{2002}{,}{"some/resource?with=search"}{,}{"user"}{,}{"passwd"}$ (5)

References

 Information Sciences Institute, "RFC 1738 Uniform Resource Locators (URL)," ISI Home Page, http://www.isi.edu/in-notes/rfc1738.txt; accessed 17 November 2005.