source: project/wiki/uri-generic @ 11992

Last change on this file since 11992 was 11992, checked in by Ivan Raikov, 13 years ago

Version set to 1.8

File size: 5.6 KB
Line 
1[[tags: eggs]]
2[[toc:]]
3
4== uri-generic
5
6=== Description
7
8The {{uri-generic}} library contains procedures for parsing and
9manipulation of Uniform Resource Identifiers
10([[http://tools.ietf.org/html/rfc3986|RFC 3986]]). It is intended to
11conform more closely to the RFC, and uses combinator parsing and
12character classes rather than regular expressions.
13
14This library should be considered to be a ''basis'' for creating
15scheme-specific URI parser libraries. This library only parses
16the generic components from an URI.  Any specific library can
17further parse subcomponents. For this reason, encoding and decoding
18of percent-encoded characters is not done automatically.
19This should be handled by specific URI scheme implementations.
20
21=== Library Procedures
22
23==== Constructors
24
25As specified in section 2.3 of RFC 3986, URI constructors
26automatically decode percent-encoded octets in the range of unreserved
27characters. This means that the following holds true:
28
29 (equal? (uri-reference "http://example.com/foo-bar")
30         (uri-reference "http://example.com/foo%2Dbar"))  => #t
31
32<procedure>(uri-reference STRING) => URI</procedure>
33
34A URI reference is either a URI or a relative reference (RFC 3986,
35Section 4.1).  If the given string's prefix does not match the syntax
36of a scheme followed by a colon separator, then the given string is
37parsed as a relative reference.
38
39<procedure>(absolute-uri STRING) => URI</procedure>
40
41Parses the given string as an absolute URI, in which no fragments are
42allowed (RFC 3986, Section 4.2)
43
44
45==== Predicates and Accessors
46
47<procedure>(uri? URI) => BOOL</procedure>
48<procedure>(uri-authority URI) => URI-AUTH</procedure>
49<procedure>(uri-scheme URI) => SYMBOL</procedure>
50<procedure>(uri-path URI) => LIST</procedure>
51<procedure>(uri-query URI) => LIST</procedure>
52<procedure>(uri-fragment) URI => STRING</procedure>
53<procedure>(uri-host URI) => STRING</procedure>
54<procedure>(uri-port URI) => INTEGER</procedure>
55<procedure>(uri-username URI) => STRING</procedure>
56<procedure>(uri-password URI) => STRING</procedure>
57
58If a component is not defined in the given URI, then the corresponding
59accessor returns {{#f}}.
60
61==== String and List Representations
62
63<procedure>(uri->string URI USERINFO) => STRING</procedure>
64
65Reconstructs the give URI into a string; uses a supplied function
66{{LAMBDA USERNAME PASSWORD -> STRING}} to map the userinfo part of the
67URI
68
69<procedure>(uri->list URI USERINFO) => LIST</procedure>
70
71Returns a list of the form {{(SCHEME SPECIFIC FRAGMENT)}};
72{{SPECIFIC}} is of the form {{(AUTHORITY PATH QUERY)}}.
73
74==== Reference Resolution
75
76<procedure>(uri-relative-to URI URI) => URI</procedure>
77
78Constructs an absolute URI given a relative URI and a base URI (RFC 3986, Section 5.2.2)
79
80<procedure>(uri-relative-from URI URI) => URI</procedure>
81
82Constructs a new, possibly relative, URI which represents the location
83of the first URI with respect to the second URI.
84
85==== String encoding and decoding
86
87<procedure>(uri-encode-string STRING) => STRING</procedure>
88
89Returns the percent-encoded form of the given string.
90
91<procedure>(uri-decode-string STRING) => STRING</procedure>
92
93Returns the decoded form of the given string.
94
95
96==== Normalization 
97
98<procedure>(uri-normalize-case URI) => URI</procedure>
99
100URI case normalization (RFC 3986 section 6.2.2.1)
101
102<procedure>(uri-normalize-path-segments URI) => URI</procedure>
103
104URI path segment normalization (RFC 3986 section 6.2.2.3)
105
106=== Requires
107
108; [[matchable]]
109; [[defstruct]]
110
111=== Version History
112
113* 1.8 Added uri-encode-string and uri-decode-string.
114      URI constructors now perform automatic normalization
115      of percent-encoded unreserved characters. [suggested by Peter Bex]
116* 1.6 Added error message about missing scheme in absolute-uri.
117* trunk Small bugfix in absolute-uri. [Peter Bex]
118* 1.5 Bug fixes in uri->string and absolute-uri. [reported by Peter Bex]
119* 1.3 Ported to Hygienic Chicken and the [[test]] egg [Peter Bex]
120* 1.2 Now using defstruct instead of define-record [suggested by Peter Bex]
121* 1.1 Added utf8 compatibility
122* 1.0 Initial Release
123
124=== License
125
126Based on the
127[[http://www.ninebynine.org/Software/ReadMe-URI-Haskell.txt|Haskell
128URI library]] by Graham Klyne <gk@ninebynine.org>.
129
130Copyright 2008 Ivan Raikov, Peter Bex.
131
132Redistribution and use in source and binary forms, with or without
133modification, are permitted provided that the following conditions are
134met:
135
136- Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
137
138- Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
139
140- Neither name of the copyright holders nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
141
142THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND THE CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
143
Note: See TracBrowser for help on using the repository browser.