URL processing
== Description ==
This page describes the facilities supported by HOP for decoding and
parsing URLs.
== Synopsis ==
=== Server ===
(url-encode url)
(url-path-encode url)
(url-decode url)
(url-decode! url)
(url-parse url)
(make-hop-url-name abspath)
=== Server & Client ===
(dirname path)
(basename path)
== Examples ==
url-, dirname, basename
== Server Definitions ==
=== ++(url-encode url) ===
url-encode
^ arguments ^ type ^ short description ^
| url | string | the URL. |
Encodes a URL according to the HTTP conventions so that characters
are no longer interpreted as arguments delimiters. Since the encoding
is similar to the one used for encoding XML strings
(see ++xml-string-encode++), encoded URLs can be decoded using
++xml-string-decode++.
~~ Example:
(url-encode "http://www.kernel.org:80?a0=val0&a1=val1&a2=val2")
,(begin "⇒")
,(STRING> (url-encode "http://www.kernel.org:80?a0=val0&a1=val1&a2=val2"))
(url-encode "http://www.kernel.org/\"foo\""
,(begin "⇒")
,(STRING> (url-encode "http://www.kernel.org/\"foo\""))
=== ++(url-path-encode url) ===
url-path-encode
^ arguments ^ type ^ short description ^
| url | string | the URL. |
Encodes a URL path according to the HTTP conventions so that characters
are no longer interpreted as arguments delimiters. Since the encoding
is similar to the one used for encoding XML strings
(see ++xml-string-encode++), encoded URLs can be decoded using
++xml-string-decode++.
~~ Example:
(url-path-encode "www.kernel.org?a0=val0&a1=val1&a2=val2")
,(begin "⇒")
,(STRING> (url-path-encode "www.kernel.org?a0=val0&a1=val1&a2=val2"))
(url-path-encode "www.kernel.org/\"foo\""
,(begin "⇒")
,(STRING> (url-path-encode "www.kernel.org/\"foo\""))
=== ++(url-parse url) ===
url-parse
^ arguments ^ type ^ short description ^
| url | string | the URL. |
Parses a URL in order to decompose it. This function returns a multiple
value composed of:
- the protocol used.
- the user information.
- the host.
- the port.
- the path.
~~ Example:
(multiple-value-bind (proto uinfo host port path)
(url-parse "https://foo:bar@nowhere.org:4567/tmp/")
(list proto uinfo host port path))
,(begin "⇒")
,(STRING>
(multiple-value-bind (proto uinfo host port path)
(url-parse "https://foo:bar@nowhere.org:4567/tmp/")
(list proto uinfo host port path)))
=== ++(url-decode url) ===
=== ++(url-decode! url) ===
url-decode
url-decode!
^ arguments ^ type ^ short description ^
| url | string | the URL. |
Decodes an encoded URL according to the HTTP conventions so that characters
are no longer interpreted as arguments delimiters. Since the encoding
is similar to the one used for encoding XML strings
(see ++xml-string-encode++), encoded URLs can be decoded using
++xml-string-decode++.
~~ ++url-decode!++ modifies its argument while ++url-decode++ creates a new
string.
~~ Example:
(url-decode ,(url-encode "www.kernel.org?a0=val0&a1=val1&a2=val2"))
,(begin "⇒")
,(STRING> "www.kernel.org?a0=val0&a1=val1&a2=val2")
(url-encode ,(url-encode "www.kernel.org/\"foo\""))
,(begin "⇒")
,(STRING> "www.kernel.org/\"foo\"")
=== ++(make-hop-url-name abspath) ===
make-hop-url-name
^ arguments ^ type ^ short description ^
| abspath | string | a path. |
The function ++make-hop-url-name++ builds a complete URL as used in a HOP
service. The function ++make-hop-url-name++ prefixes the ++abspath++ argument
with the common prefix used by all HOP services, generally the prefix ++/hop++.
== Server & Client Definitions ==
=== ++(basename abspath) ===
basename
^ arguments ^ type ^ short description ^
| abspath | string | a path. |
Returns a copy of ++abspath++ where the longest prefix ending in ++/++ is
deleted if any existed.
=== ++(dirname abspath) ===
dirname
^ arguments ^ type ^ short description ^
| abspath | string | a path. |
Returns a new string which is the directory component of ++string++.
For instance:
(dirname "abc/def/ghi")
,(begin "⇒")
"abc/def"
(dirname "abc")
,(begin "⇒")
"."
(dirname "abc/")
,(begin "⇒")
"abc"
(dirname "/abc")
,(begin "⇒")
"/"
== See also ==
url-, xml-string-decode