1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
15 * The Original Code is mozilla.org code.
17 * The Initial Developer of the Original Code is
18 * Netscape Communications Corporation.
19 * Portions created by the Initial Developer are Copyright (C) 1998
20 * the Initial Developer. All Rights Reserved.
23 * Gagan Saksena <gagan@netscape.com> (original author)
24 * Darin Fisher <darin@netscape.com>
26 * Alternatively, the contents of this file may be used under the terms of
27 * either the GNU General Public License Version 2 or later (the "GPL"), or
28 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
29 * in which case the provisions of the GPL or the LGPL are applicable instead
30 * of those above. If you wish to allow use of your version of this file only
31 * under the terms of either the GPL or the LGPL, and not to allow others to
32 * use your version of this file under the terms of the MPL, indicate your
33 * decision by deleting the provisions above and replace them with the notice
34 * and other provisions required by the GPL or the LGPL. If you do not delete
35 * the provisions above, a recipient may use your version of this file under
36 * the terms of any one of the MPL, the GPL or the LGPL.
38 * ***** END LICENSE BLOCK ***** */
40 #include
"nsISupports.idl"
43 * URIs are essentially structured names for things -- anything. This interface
44 * provides accessors to set and query the most basic components of an URI.
45 * Subclasses, including nsIURL, impose greater structure on the URI.
47 * This interface follows Tim Berners-Lee's URI spec (RFC2396) [1], where the
48 * basic URI components are defined as such:
50 * ftp://username:password@hostname:portnumber/pathname
52 * - --------------- ------ -------- -------
60 * --------------------------------
64 * The definition of the URI components has been extended to allow for
65 * internationalized domain names [2] and the more generic IRI structure [3].
67 * [1] http://www.ietf.org/rfc/rfc2396.txt
68 * [2] http://www.ietf.org/internet-drafts/draft-ietf-idn-idna-06.txt
69 * [3] http://www.ietf.org/internet-drafts/draft-masinter-url-i18n-08.txt
73 #undef GetPort
// XXX Windows!
74 #undef SetPort
// XXX Windows!
78 * nsIURI - interface for an uniform resource identifier w/ i18n support.
80 * AUTF8String attributes may contain unescaped UTF-8 characters.
81 * Consumers should be careful to escape the UTF-8 strings as necessary, but
82 * should always try to "display" the UTF-8 version as provided by this
85 * AUTF8String attributes may also contain escaped characters.
87 * Unescaping URI segments is unadvised unless there is intimate
88 * knowledge of the underlying charset or there is no plan to display (or
89 * otherwise enforce a charset on) the resulting URI substring.
91 * The correct way to create an nsIURI from a string is via
92 * nsIIOService.newURI.
96 [scriptable
, uuid(07a22cc0
-0ce5
-11d3
-9331-00104ba0fd40
)]
97 interface nsIURI
: nsISupports
99 /************************************************************************
100 * The URI is broken down into the following principal components:
104 * Returns a string representation of the URI. Setting the spec causes
105 * the new spec to be parsed per the rules for the scheme the URI
106 * currently has. In particular, setting the spec to a URI string with a
107 * different scheme will generally produce incorrect results; no one
108 * outside of a protocol handler implementation should be doing that. If
109 * the URI stores information from the nsIIOService.newURI call used to
110 * create it other than just the parsed string, then behavior of this
111 * information on setting the spec attribute is undefined.
113 * Some characters may be escaped.
115 attribute AUTF8String spec
;
118 * The prePath (eg. scheme://user:password@host:port) returns the string
119 * before the path. This is useful for authentication or managing sessions.
121 * Some characters may be escaped.
123 readonly attribute AUTF8String prePath
;
126 * The Scheme is the protocol to which this URI refers. The scheme is
127 * restricted to the US-ASCII charset per RFC2396. Setting this is
128 * highly discouraged outside of a protocol handler implementation, since
129 * that will generally lead to incorrect results.
131 attribute ACString scheme
;
134 * The username:password (or username only if value doesn't contain a ':')
136 * Some characters may be escaped.
138 attribute AUTF8String userPass
;
141 * The optional username and password, assuming the preHost consists of
144 * Some characters may be escaped.
146 attribute AUTF8String username
;
147 attribute AUTF8String password
;
150 * The host:port (or simply the host, if port == -1).
152 * Characters are NOT escaped.
154 attribute AUTF8String hostPort
;
157 * The host is the internet domain name to which this URI refers. It could
158 * be an IPv4 (or IPv6) address literal. If supported, it could be a
159 * non-ASCII internationalized domain name.
161 * Characters are NOT escaped.
163 attribute AUTF8String host
;
166 * A port value of -1 corresponds to the protocol's default port (eg. -1
167 * implies port 80 for http URIs).
172 * The path, typically including at least a leading '/' (but may also be
173 * empty, depending on the protocol).
175 * Some characters may be escaped.
177 attribute AUTF8String path
;
180 /************************************************************************
181 * An URI supports the following methods:
185 * URI equivalence test (not a strict string comparison).
187 * eg. http://foo.com:80/ == http://foo.com/
189 boolean equals
(in nsIURI other
);
192 * An optimization to do scheme checks without requiring the users of nsIURI
193 * to GetScheme, thereby saving extra allocating and freeing. Returns true if
194 * the schemes match (case ignored).
196 boolean schemeIs
(in string scheme
);
199 * Clones the current URI. For some protocols, this is more than just an
200 * optimization. For example, under MacOS, the spec of a file URL does not
201 * necessarily uniquely identify a file since two volumes could share the
207 * This method resolves a relative string into an absolute URI string,
208 * using this URI as the base.
210 * NOTE: some implementations may have no concept of a relative URI.
212 AUTF8String resolve
(in AUTF8String relativePath
);
215 /************************************************************************
216 * Additional attributes:
220 * The URI spec with an ASCII compatible encoding. Host portion follows
221 * the IDNA draft spec. Other parts are URL-escaped per the rules of
222 * RFC2396. The result is strictly ASCII.
224 readonly attribute ACString asciiSpec
;
227 * The URI host with an ASCII compatible encoding. Follows the IDNA
228 * draft spec for converting internationalized domain names (UTF-8) to
229 * ASCII for compatibility with existing internet infrasture.
231 readonly attribute ACString asciiHost
;
234 * The charset of the document from which this URI originated. An empty
235 * value implies UTF-8.
237 * If this value is something other than UTF-8 then the URI components
238 * (e.g., spec, prePath, username, etc.) will all be fully URL-escaped.
239 * Otherwise, the URI components may contain unescaped multibyte UTF-8
242 readonly attribute ACString originCharset
;