source: project/wiki/eggref/4/uri-common @ 12976

Last change on this file since 12976 was 12976, checked in by sjamaan, 12 years ago

Add documentation about urlencoding procedures

File size: 4.3 KB
Line 
1[[tags: eggs]]
2[[toc:]]
3
4== uri-common
5
6=== Description
7
8The {{uri-common}} library provides simple and easy-to-use parsing
9and manipulation procedures for URIs using common schemes.
10
11These "common schemes" all have the following rules:
12
13* An empty path after the hostname is considered to be identical to the root path.
14* All components are to be fully URI-decoded (so no percent-encoded characters in it).
15* The query argument will be in
16   [[http://www.w3.org/TR/html401/interact/forms.html#h-17.13.4.1|application/x-www-form-urlencoded]] form.
17* The port is automatically determined if it is omitted and the URI scheme is known.
18
19=== Library Procedures
20
21==== Constructors
22
23<procedure>(uri-common arg) => uri-common</procedure>
24
25Construct a new uri-common object. The {{ARG}} can be either an
26{{URI}} (an [[uri-generic]] object) or a string.
27
28==== Predicates and Accessors
29
30* <procedure>(uri-common? uri-common) => bool</procedure>
31* <procedure>(uri-common-generic uri-common) => symbol</procedure>
32* <procedure>(uri-common-scheme uri-common) => symbol</procedure>
33* <procedure>(uri-common-path uri-common) => list</procedure>
34* <procedure>(uri-common-query uri-common) => alist</procedure>
35* <procedure>(uri-common-fragment uri-common) => string</procedure>
36* <procedure>(uri-common-host uri-common) => string</procedure>
37* <procedure>(uri-common-port uri-common) => integer</procedure>
38* <procedure>(uri-common-username uri-common) => string</procedure>
39* <procedure>(uri-common-password uri-common) => string</procedure>
40
41If a component is not defined in the given URI-common, then the
42corresponding accessor returns {{#f}}.
43
44* <procedure>(update-uri-common URI-common #!key scheme path query fragment host port username password) => URI-common</procedure>
45
46Update the specified keys in the URI-common object in a functional way
47(ie, it creates a new copy with the modifications).
48
49==== Query encoding and decoding
50
51* <parameter>(form-urlencoded-separator [char-set/char/string])</parameter>
52* <procedure>(form-urlencode alist #!key (separator (form-urlencoded-separator))) => string</procedure>
53* <procedure>(form-urldecode string #!key (separator (form-urlencoded-separator))) => alist</procedure>
54
55Encode or decode an alist using the encoding corresponding to the
56[[http://www.w3.org/TR/html401/interact/forms.html#h-17.13.4.1|form-urlencoded]]
57media type, using the given separator character(s).
58
59When encoding, if {{separator}} is a string, the first character will
60be used as the separator in the resulting querystring.  If it is a
61char-set, it will be converted to a string and its first character
62will be taken.  In either case, all of these characters are encoded if
63they occur inside the key/value pairs.
64
65When decoding, any character in the set (or string) will be seen as
66a separator.
67
68The separator defaults to the ampersand character.
69
70=== Requires
71
72* [[uri-generic]]
73* [[matchable]]
74* [[defstruct]]
75
76=== Version History
77
78* 0.1 Initial Release
79
80=== License
81
82Copyright 2008-2009 Peter Bex.
83
84Redistribution and use in source and binary forms, with or without
85modification, are permitted provided that the following conditions are
86met:
87
88- Redistributions of source code must retain the above copyright
89  notice, this list of conditions and the following disclaimer.
90
91- Redistributions in binary form must reproduce the above copyright
92  notice, this list of conditions and the following disclaimer in the
93  documentation and/or other materials provided with the distribution.
94
95- Neither name of the copyright holders nor the names of its
96  contributors may be used to endorse or promote products derived from
97  this software without specific prior written permission.
98
99THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND THE
100CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
101BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
102FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
103COPYRIGHT HOLDERS OR THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
104INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
105(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
106SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
107HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
108STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
109IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
110POSSIBILITY OF SUCH DAMAGE.
111
Note: See TracBrowser for help on using the repository browser.