RFC2396 (Line Numbered)

[Below is a line-numbered copy of http://www.ietf.org/rfc/rfc2396.txt obtained on 21-Jan-2003. It is referenced from 'What Part of "Resource" Don't I Understand?', by David Booth, which analyzes -- line by line -- the definition of "resource" in RFC2396. The line numbers (and this comment) are for reference only, and are NOT a part of RFC2396.]


   1. 
   2. 
   3. 
   4. 
   5. 
   6. Network Working Group                                     T. Berners-Lee
   7. Request for Comments: 2396                                       MIT/LCS
   8. Updates: 1808, 1738                                          R. Fielding
   9. Category: Standards Track                                    U.C. Irvine
  10.                                                              L. Masinter
  11.                                                        Xerox Corporation
  12.                                                              August 1998
  13. 
  14. 
  15.            Uniform Resource Identifiers (URI): Generic Syntax
  16. 
  17. Status of this Memo
  18. 
  19.    This document specifies an Internet standards track protocol for the
  20.    Internet community, and requests discussion and suggestions for
  21.    improvements.  Please refer to the current edition of the "Internet
  22.    Official Protocol Standards" (STD 1) for the standardization state
  23.    and status of this protocol.  Distribution of this memo is unlimited.
  24. 
  25. Copyright Notice
  26. 
  27.    Copyright (C) The Internet Society (1998).  All Rights Reserved.
  28. 
  29. IESG Note
  30. 
  31.    This paper describes a "superset" of operations that can be applied
  32.    to URI.  It consists of both a grammar and a description of basic
  33.    functionality for URI.  To understand what is a valid URI, both the
  34.    grammar and the associated description have to be studied.  Some of
  35.    the functionality described is not applicable to all URI schemes, and
  36.    some operations are only possible when certain media types are
  37.    retrieved using the URI, regardless of the scheme used.
  38. 
  39. Abstract
  40. 
  41.    A Uniform Resource Identifier (URI) is a compact string of characters
  42.    for identifying an abstract or physical resource.  This document
  43.    defines the generic syntax of URI, including both absolute and
  44.    relative forms, and guidelines for their use; it revises and replaces
  45.    the generic definitions in RFC 1738 and RFC 1808.
  46. 
  47.    This document defines a grammar that is a superset of all valid URI,
  48.    such that an implementation can parse the common components of a URI
  49.    reference without knowing the scheme-specific requirements of every
  50.    possible identifier type.  This document does not define a generative
  51.    grammar for URI; that task will be performed by the individual
  52.    specifications of each URI scheme.
  53. 
  54. 
  55. 
  56. 
  57. Berners-Lee, et. al.        Standards Track                     [Page 1]
  58.  


  59. RFC 2396                   URI Generic Syntax                August 1998
  60. 
  61. 
  62. 1. Introduction
  63. 
  64.    Uniform Resource Identifiers (URI) provide a simple and extensible
  65.    means for identifying a resource.  This specification of URI syntax
  66.    and semantics is derived from concepts introduced by the World Wide
  67.    Web global information initiative, whose use of such objects dates
  68.    from 1990 and is described in "Universal Resource Identifiers in WWW"
  69.    [RFC1630].  The specification of URI is designed to meet the
  70.    recommendations laid out in "Functional Recommendations for Internet
  71.    Resource Locators" [RFC1736] and "Functional Requirements for Uniform
  72.    Resource Names" [RFC1737].
  73. 
  74.    This document updates and merges "Uniform Resource Locators"
  75.    [RFC1738] and "Relative Uniform Resource Locators" [RFC1808] in order
  76.    to define a single, generic syntax for all URI.  It excludes those
  77.    portions of RFC 1738 that defined the specific syntax of individual
  78.    URL schemes; those portions will be updated as separate documents, as
  79.    will the process for registration of new URI schemes.  This document
  80.    does not discuss the issues and recommendation for dealing with
  81.    characters outside of the US-ASCII character set [ASCII]; those
  82.    recommendations are discussed in a separate document.
  83. 
  84.    All significant changes from the prior RFCs are noted in Appendix G.
  85. 
  86. 1.1 Overview of URI
  87. 
  88.    URI are characterized by the following definitions:
  89. 
  90.       Uniform
  91.          Uniformity provides several benefits: it allows different types
  92.          of resource identifiers to be used in the same context, even
  93.          when the mechanisms used to access those resources may differ;
  94.          it allows uniform semantic interpretation of common syntactic
  95.          conventions across different types of resource identifiers; it
  96.          allows introduction of new types of resource identifiers
  97.          without interfering with the way that existing identifiers are
  98.          used; and, it allows the identifiers to be reused in many
  99.          different contexts, thus permitting new applications or
 100.          protocols to leverage a pre-existing, large, and widely-used
 101.          set of resource identifiers.
 102. 
 103.       Resource
 104.          A resource can be anything that has identity.  Familiar
 105.          examples include an electronic document, an image, a service
 106.          (e.g., "today's weather report for Los Angeles"), and a
 107.          collection of other resources.  Not all resources are network
 108.          "retrievable"; e.g., human beings, corporations, and bound
 109.          books in a library can also be considered resources.
 110. 
 111. 
 112. 
 113. Berners-Lee, et. al.        Standards Track                     [Page 2]
 114.  


 115. RFC 2396                   URI Generic Syntax                August 1998
 116. 
 117. 
 118.          The resource is the conceptual mapping to an entity or set of
 119.          entities, not necessarily the entity which corresponds to that
 120.          mapping at any particular instance in time.  Thus, a resource
 121.          can remain constant even when its content---the entities to
 122.          which it currently corresponds---changes over time, provided
 123.          that the conceptual mapping is not changed in the process.
 124. 
 125.       Identifier
 126.          An identifier is an object that can act as a reference to
 127.          something that has identity.  In the case of URI, the object is
 128.          a sequence of characters with a restricted syntax.
 129. 
 130.    Having identified a resource, a system may perform a variety of
 131.    operations on the resource, as might be characterized by such words
 132.    as `access', `update', `replace', or `find attributes'.
 133. 
 134. 1.2. URI, URL, and URN
 135. 
 136.    A URI can be further classified as a locator, a name, or both.  The
 137.    term "Uniform Resource Locator" (URL) refers to the subset of URI
 138.    that identify resources via a representation of their primary access
 139.    mechanism (e.g., their network "location"), rather than identifying
 140.    the resource by name or by some other attribute(s) of that resource.
 141.    The term "Uniform Resource Name" (URN) refers to the subset of URI
 142.    that are required to remain globally unique and persistent even when
 143.    the resource ceases to exist or becomes unavailable.
 144. 
 145.    The URI scheme (Section 3.1) defines the namespace of the URI, and
 146.    thus may further restrict the syntax and semantics of identifiers
 147.    using that scheme.  This specification defines those elements of the
 148.    URI syntax that are either required of all URI schemes or are common
 149.    to many URI schemes.  It thus defines the syntax and semantics that
 150.    are needed to implement a scheme-independent parsing mechanism for
 151.    URI references, such that the scheme-dependent handling of a URI can
 152.    be postponed until the scheme-dependent semantics are needed.  We use
 153.    the term URL below when describing syntax or semantics that only
 154.    apply to locators.
 155. 
 156.    Although many URL schemes are named after protocols, this does not
 157.    imply that the only way to access the URL's resource is via the named
 158.    protocol.  Gateways, proxies, caches, and name resolution services
 159.    might be used to access some resources, independent of the protocol
 160.    of their origin, and the resolution of some URL may require the use
 161.    of more than one protocol (e.g., both DNS and HTTP are typically used
 162.    to access an "http" URL's resource when it can't be found in a local
 163.    cache).
 164. 
 165. 
 166. 
 167. 
 168. 
 169. Berners-Lee, et. al.        Standards Track                     [Page 3]
 170.  


 171. RFC 2396                   URI Generic Syntax                August 1998
 172. 
 173. 
 174.    A URN differs from a URL in that it's primary purpose is persistent
 175.    labeling of a resource with an identifier.  That identifier is drawn
 176.    from one of a set of defined namespaces, each of which has its own
 177.    set name structure and assignment procedures.  The "urn" scheme has
 178.    been reserved to establish the requirements for a standardized URN
 179.    namespace, as defined in "URN Syntax" [RFC2141] and its related
 180.    specifications.
 181. 
 182.    Most of the examples in this specification demonstrate URL, since
 183.    they allow the most varied use of the syntax and often have a
 184.    hierarchical namespace.  A parser of the URI syntax is capable of
 185.    parsing both URL and URN references as a generic URI; once the scheme
 186.    is determined, the scheme-specific parsing can be performed on the
 187.    generic URI components.  In other words, the URI syntax is a superset
 188.    of the syntax of all URI schemes.
 189. 
 190. 1.3. Example URI
 191. 
 192.    The following examples illustrate URI that are in common use.
 193. 
 194.    ftp://ftp.is.co.za/rfc/rfc1808.txt
 195.       -- ftp scheme for File Transfer Protocol services
 196. 
 197.    gopher://spinaltap.micro.umn.edu/00/Weather/California/Los%20Angeles
 198.       -- gopher scheme for Gopher and Gopher+ Protocol services
 199. 
 200.    http://www.math.uio.no/faq/compression-faq/part1.html
 201.       -- http scheme for Hypertext Transfer Protocol services
 202. 
 203.    mailto:mduerst@ifi.unizh.ch
 204.       -- mailto scheme for electronic mail addresses
 205. 
 206.    news:comp.infosystems.www.servers.unix
 207.       -- news scheme for USENET news groups and articles
 208. 
 209.    telnet://melvyl.ucop.edu/
 210.       -- telnet scheme for interactive services via the TELNET Protocol
 211. 
 212. 1.4. Hierarchical URI and Relative Forms
 213. 
 214.    An absolute identifier refers to a resource independent of the
 215.    context in which the identifier is used.  In contrast, a relative
 216.    identifier refers to a resource by describing the difference within a
 217.    hierarchical namespace between the current context and an absolute
 218.    identifier of the resource.
 219. 
 220. 
 221. 
 222. 
 223. 
 224. 
 225. Berners-Lee, et. al.        Standards Track                     [Page 4]
 226.  


 227. RFC 2396                   URI Generic Syntax                August 1998
 228. 
 229. 
 230.    Some URI schemes support a hierarchical naming system, where the
 231.    hierarchy of the name is denoted by a "/" delimiter separating the
 232.    components in the scheme. This document defines a scheme-independent
 233.    `relative' form of URI reference that can be used in conjunction with
 234.    a `base' URI (of a hierarchical scheme) to produce another URI. The
 235.    syntax of hierarchical URI is described in Section 3; the relative
 236.    URI calculation is described in Section 5.
 237. 
 238. 1.5. URI Transcribability
 239. 
 240.    The URI syntax was designed with global transcribability as one of
 241.    its main concerns. A URI is a sequence of characters from a very
 242.    limited set, i.e. the letters of the basic Latin alphabet, digits,
 243.    and a few special characters.  A URI may be represented in a variety
 244.    of ways: e.g., ink on paper, pixels on a screen, or a sequence of
 245.    octets in a coded character set.  The interpretation of a URI depends
 246.    only on the characters used and not how those characters are
 247.    represented in a network protocol.
 248. 
 249.    The goal of transcribability can be described by a simple scenario.
 250.    Imagine two colleagues, Sam and Kim, sitting in a pub at an
 251.    international conference and exchanging research ideas.  Sam asks Kim
 252.    for a location to get more information, so Kim writes the URI for the
 253.    research site on a napkin.  Upon returning home, Sam takes out the
 254.    napkin and types the URI into a computer, which then retrieves the
 255.    information to which Kim referred.
 256. 
 257.    There are several design concerns revealed by the scenario:
 258. 
 259.       o  A URI is a sequence of characters, which is not always
 260.          represented as a sequence of octets.
 261. 
 262.       o  A URI may be transcribed from a non-network source, and thus
 263.          should consist of characters that are most likely to be able to
 264.          be typed into a computer, within the constraints imposed by
 265.          keyboards (and related input devices) across languages and
 266.          locales.
 267. 
 268.       o  A URI often needs to be remembered by people, and it is easier
 269.          for people to remember a URI when it consists of meaningful
 270.          components.
 271. 
 272.    These design concerns are not always in alignment.  For example, it
 273.    is often the case that the most meaningful name for a URI component
 274.    would require characters that cannot be typed into some systems.  The
 275.    ability to transcribe the resource identifier from one medium to
 276.    another was considered more important than having its URI consist of
 277.    the most meaningful of components.  In local and regional contexts
 278. 
 279. 
 280. 
 281. Berners-Lee, et. al.        Standards Track                     [Page 5]
 282.  


 283. RFC 2396                   URI Generic Syntax                August 1998
 284. 
 285. 
 286.    and with improving technology, users might benefit from being able to
 287.    use a wider range of characters; such use is not defined in this
 288.    document.
 289. 
 290. 1.6. Syntax Notation and Common Elements
 291. 
 292.    This document uses two conventions to describe and define the syntax
 293.    for URI.  The first, called the layout form, is a general description
 294.    of the order of components and component separators, as in
 295. 
 296.       /;?
 297. 
 298.    The component names are enclosed in angle-brackets and any characters
 299.    outside angle-brackets are literal separators.  Whitespace should be
 300.    ignored.  These descriptions are used informally and do not define
 301.    the syntax requirements.
 302. 
 303.    The second convention is a BNF-like grammar, used to define the
 304.    formal URI syntax.  The grammar is that of [RFC822], except that "|"
 305.    is used to designate alternatives.  Briefly, rules are separated from
 306.    definitions by an equal "=", indentation is used to continue a rule
 307.    definition over more than one line, literals are quoted with "",
 308.    parentheses "(" and ")" are used to group elements, optional elements
 309.    are enclosed in "[" and "]" brackets, and elements may be preceded
 310.    with * to designate n or more repetitions of the following
 311.    element; n defaults to 0.
 312. 
 313.    Unlike many specifications that use a BNF-like grammar to define the
 314.    bytes (octets) allowed by a protocol, the URI grammar is defined in
 315.    terms of characters.  Each literal in the grammar corresponds to the
 316.    character it represents, rather than to the octet encoding of that
 317.    character in any particular coded character set.  How a URI is
 318.    represented in terms of bits and bytes on the wire is dependent upon
 319.    the character encoding of the protocol used to transport it, or the
 320.    charset of the document which contains it.
 321. 
 322.    The following definitions are common to many elements:
 323. 
 324.       alpha    = lowalpha | upalpha
 325. 
 326.       lowalpha = "a" | "b" | "c" | "d" | "e" | "f" | "g" | "h" | "i" |
 327.                  "j" | "k" | "l" | "m" | "n" | "o" | "p" | "q" | "r" |
 328.                  "s" | "t" | "u" | "v" | "w" | "x" | "y" | "z"
 329. 
 330.       upalpha  = "A" | "B" | "C" | "D" | "E" | "F" | "G" | "H" | "I" |
 331.                  "J" | "K" | "L" | "M" | "N" | "O" | "P" | "Q" | "R" |
 332.                  "S" | "T" | "U" | "V" | "W" | "X" | "Y" | "Z"
 333. 
 334. 
 335. 
 336. 
 337. Berners-Lee, et. al.        Standards Track                     [Page 6]
 338.  


 339. RFC 2396                   URI Generic Syntax                August 1998
 340. 
 341. 
 342.       digit    = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" |
 343.                  "8" | "9"
 344. 
 345.       alphanum = alpha | digit
 346. 
 347.    The complete URI syntax is collected in Appendix A.
 348. 
 349. 2. URI Characters and Escape Sequences
 350. 
 351.    URI consist of a restricted set of characters, primarily chosen to
 352.    aid transcribability and usability both in computer systems and in
 353.    non-computer communications. Characters used conventionally as
 354.    delimiters around URI were excluded.  The restricted set of
 355.    characters consists of digits, letters, and a few graphic symbols
 356.    were chosen from those common to most of the character encodings and
 357.    input facilities available to Internet users.
 358. 
 359.       uric          = reserved | unreserved | escaped
 360. 
 361.    Within a URI, characters are either used as delimiters, or to
 362.    represent strings of data (octets) within the delimited portions.
 363.    Octets are either represented directly by a character (using the US-
 364.    ASCII character for that octet [ASCII]) or by an escape encoding.
 365.    This representation is elaborated below.
 366. 
 367. 2.1 URI and non-ASCII characters
 368. 
 369.    The relationship between URI and characters has been a source of
 370.    confusion for characters that are not part of US-ASCII. To describe
 371.    the relationship, it is useful to distinguish between a "character"
 372.    (as a distinguishable semantic entity) and an "octet" (an 8-bit
 373.    byte). There are two mappings, one from URI characters to octets, and
 374.    a second from octets to original characters:
 375. 
 376.    URI character sequence->octet sequence->original character sequence
 377. 
 378.    A URI is represented as a sequence of characters, not as a sequence
 379.    of octets. That is because URI might be "transported" by means that
 380.    are not through a computer network, e.g., printed on paper, read over
 381.    the radio, etc.
 382. 
 383.    A URI scheme may define a mapping from URI characters to octets;
 384.    whether this is done depends on the scheme. Commonly, within a
 385.    delimited component of a URI, a sequence of characters may be used to
 386.    represent a sequence of octets. For example, the character "a"
 387.    represents the octet 97 (decimal), while the character sequence "%",
 388.    "0", "a" represents the octet 10 (decimal).
 389. 
 390. 
 391. 
 392. 
 393. Berners-Lee, et. al.        Standards Track                     [Page 7]
 394.  


 395. RFC 2396                   URI Generic Syntax                August 1998
 396. 
 397. 
 398.    There is a second translation for some resources: the sequence of
 399.    octets defined by a component of the URI is subsequently used to
 400.    represent a sequence of characters. A 'charset' defines this mapping.
 401.    There are many charsets in use in Internet protocols. For example,
 402.    UTF-8 [UTF-8] defines a mapping from sequences of octets to sequences
 403.    of characters in the repertoire of ISO 10646.
 404. 
 405.    In the simplest case, the original character sequence contains only
 406.    characters that are defined in US-ASCII, and the two levels of
 407.    mapping are simple and easily invertible: each 'original character'
 408.    is represented as the octet for the US-ASCII code for it, which is,
 409.    in turn, represented as either the US-ASCII character, or else the
 410.    "%" escape sequence for that octet.
 411. 
 412.    For original character sequences that contain non-ASCII characters,
 413.    however, the situation is more difficult. Internet protocols that
 414.    transmit octet sequences intended to represent character sequences
 415.    are expected to provide some way of identifying the charset used, if
 416.    there might be more than one [RFC2277].  However, there is currently
 417.    no provision within the generic URI syntax to accomplish this
 418.    identification. An individual URI scheme may require a single
 419.    charset, define a default charset, or provide a way to indicate the
 420.    charset used.
 421. 
 422.    It is expected that a systematic treatment of character encoding
 423.    within URI will be developed as a future modification of this
 424.    specification.
 425. 
 426. 2.2. Reserved Characters
 427. 
 428.    Many URI include components consisting of or delimited by, certain
 429.    special characters.  These characters are called "reserved", since
 430.    their usage within the URI component is limited to their reserved
 431.    purpose.  If the data for a URI component would conflict with the
 432.    reserved purpose, then the conflicting data must be escaped before
 433.    forming the URI.
 434. 
 435.       reserved    = ";" | "/" | "?" | ":" | "@" | "&" | "=" | "+" |
 436.                     "$" | ","
 437. 
 438.    The "reserved" syntax class above refers to those characters that are
 439.    allowed within a URI, but which may not be allowed within a
 440.    particular component of the generic URI syntax; they are used as
 441.    delimiters of the components described in Section 3.
 442. 
 443. 
 444. 
 445. 
 446. 
 447. 
 448. 
 449. Berners-Lee, et. al.        Standards Track                     [Page 8]
 450.  


 451. RFC 2396                   URI Generic Syntax                August 1998
 452. 
 453. 
 454.    Characters in the "reserved" set are not reserved in all contexts.
 455.    The set of characters actually reserved within any given URI
 456.    component is defined by that component. In general, a character is
 457.    reserved if the semantics of the URI changes if the character is
 458.    replaced with its escaped US-ASCII encoding.
 459. 
 460. 2.3. Unreserved Characters
 461. 
 462.    Data characters that are allowed in a URI but do not have a reserved
 463.    purpose are called unreserved.  These include upper and lower case
 464.    letters, decimal digits, and a limited set of punctuation marks and
 465.    symbols.
 466. 
 467.       unreserved  = alphanum | mark
 468. 
 469.       mark        = "-" | "_" | "." | "!" | "~" | "*" | "'" | "(" | ")"
 470. 
 471.    Unreserved characters can be escaped without changing the semantics
 472.    of the URI, but this should not be done unless the URI is being used
 473.    in a context that does not allow the unescaped character to appear.
 474. 
 475. 2.4. Escape Sequences
 476. 
 477.    Data must be escaped if it does not have a representation using an
 478.    unreserved character; this includes data that does not correspond to
 479.    a printable character of the US-ASCII coded character set, or that
 480.    corresponds to any US-ASCII character that is disallowed, as
 481.    explained below.
 482. 
 483. 2.4.1. Escaped Encoding
 484. 
 485.    An escaped octet is encoded as a character triplet, consisting of the
 486.    percent character "%" followed by the two hexadecimal digits
 487.    representing the octet code. For example, "%20" is the escaped
 488.    encoding for the US-ASCII space character.
 489. 
 490.       escaped     = "%" hex hex
 491.       hex         = digit | "A" | "B" | "C" | "D" | "E" | "F" |
 492.                             "a" | "b" | "c" | "d" | "e" | "f"
 493. 
 494. 2.4.2. When to Escape and Unescape
 495. 
 496.    A URI is always in an "escaped" form, since escaping or unescaping a
 497.    completed URI might change its semantics.  Normally, the only time
 498.    escape encodings can safely be made is when the URI is being created
 499.    from its component parts; each component may have its own set of
 500.    characters that are reserved, so only the mechanism responsible for
 501.    generating or interpreting that component can determine whether or
 502. 
 503. 
 504. 
 505. Berners-Lee, et. al.        Standards Track                     [Page 9]
 506.  


 507. RFC 2396                   URI Generic Syntax                August 1998
 508. 
 509. 
 510.    not escaping a character will change its semantics. Likewise, a URI
 511.    must be separated into its components before the escaped characters
 512.    within those components can be safely decoded.
 513. 
 514.    In some cases, data that could be represented by an unreserved
 515.    character may appear escaped; for example, some of the unreserved
 516.    "mark" characters are automatically escaped by some systems.  If the
 517.    given URI scheme defines a canonicalization algorithm, then
 518.    unreserved characters may be unescaped according to that algorithm.
 519.    For example, "%7e" is sometimes used instead of "~" in an http URL
 520.    path, but the two are equivalent for an http URL.
 521. 
 522.    Because the percent "%" character always has the reserved purpose of
 523.    being the escape indicator, it must be escaped as "%25" in order to
 524.    be used as data within a URI.  Implementers should be careful not to
 525.    escape or unescape the same string more than once, since unescaping
 526.    an already unescaped string might lead to misinterpreting a percent
 527.    data character as another escaped character, or vice versa in the
 528.    case of escaping an already escaped string.
 529. 
 530. 2.4.3. Excluded US-ASCII Characters
 531. 
 532.    Although they are disallowed within the URI syntax, we include here a
 533.    description of those US-ASCII characters that have been excluded and
 534.    the reasons for their exclusion.
 535. 
 536.    The control characters in the US-ASCII coded character set are not
 537.    used within a URI, both because they are non-printable and because
 538.    they are likely to be misinterpreted by some control mechanisms.
 539. 
 540.    control     = 
 541. 
 542.    The space character is excluded because significant spaces may
 543.    disappear and insignificant spaces may be introduced when URI are
 544.    transcribed or typeset or subjected to the treatment of word-
 545.    processing programs.  Whitespace is also used to delimit URI in many
 546.    contexts.
 547. 
 548.    space       = 
 549. 
 550.    The angle-bracket "<" and ">" and double-quote (") characters are
 551.    excluded because they are often used as the delimiters around URI in
 552.    text documents and protocol fields.  The character "#" is excluded
 553.    because it is used to delimit a URI from a fragment identifier in URI
 554.    references (Section 4). The percent character "%" is excluded because
 555.    it is used for the encoding of escaped characters.
 556. 
 557.    delims      = "<" | ">" | "#" | "%" | <">
 558. 
 559. 
 560. 
 561. Berners-Lee, et. al.        Standards Track                    [Page 10]
 562.  


 563. RFC 2396                   URI Generic Syntax                August 1998
 564. 
 565. 
 566.    Other characters are excluded because gateways and other transport
 567.    agents are known to sometimes modify such characters, or they are
 568.    used as delimiters.
 569. 
 570.    unwise      = "{" | "}" | "|" | "\" | "^" | "[" | "]" | "`"
 571. 
 572.    Data corresponding to excluded characters must be escaped in order to
 573.    be properly represented within a URI.
 574. 
 575. 3. URI Syntactic Components
 576. 
 577.    The URI syntax is dependent upon the scheme.  In general, absolute
 578.    URI are written as follows:
 579. 
 580.       :
 581. 
 582.    An absolute URI contains the name of the scheme being used ()
 583.    followed by a colon (":") and then a string (the ) whose interpretation depends on the scheme.
 585. 
 586.    The URI syntax does not require that the scheme-specific-part have
 587.    any general structure or set of semantics which is common among all
 588.    URI.  However, a subset of URI do share a common syntax for
 589.    representing hierarchical relationships within the namespace.  This
 590.    "generic URI" syntax consists of a sequence of four main components:
 591. 
 592.       ://?
 593. 
 594.    each of which, except , may be absent from a particular URI.
 595.    For example, some URI schemes do not allow an  component,
 596.    and others do not use a  component.
 597. 
 598.       absoluteURI   = scheme ":" ( hier_part | opaque_part )
 599. 
 600.    URI that are hierarchical in nature use the slash "/" character for
 601.    separating hierarchical components.  For some file systems, a "/"
 602.    character (used to denote the hierarchical structure of a URI) is the
 603.    delimiter used to construct a file name hierarchy, and thus the URI
 604.    path will look similar to a file pathname.  This does NOT imply that
 605.    the resource is a file or that the URI maps to an actual filesystem
 606.    pathname.
 607. 
 608.       hier_part     = ( net_path | abs_path ) [ "?" query ]
 609. 
 610.       net_path      = "//" authority [ abs_path ]
 611. 
 612.       abs_path      = "/"  path_segments
 613. 
 614. 
 615. 
 616. 
 617. Berners-Lee, et. al.        Standards Track                    [Page 11]
 618.  


 619. RFC 2396                   URI Generic Syntax                August 1998
 620. 
 621. 
 622.    URI that do not make use of the slash "/" character for separating
 623.    hierarchical components are considered opaque by the generic URI
 624.    parser.
 625. 
 626.       opaque_part   = uric_no_slash *uric
 627. 
 628.       uric_no_slash = unreserved | escaped | ";" | "?" | ":" | "@" |
 629.                       "&" | "=" | "+" | "$" | ","
 630. 
 631.    We use the term  to refer to both the  and
 632.     constructs, since they are mutually exclusive for any
 633.    given URI and can be parsed as a single component.
 634. 
 635. 3.1. Scheme Component
 636. 
 637.    Just as there are many different methods of access to resources,
 638.    there are a variety of schemes for identifying such resources.  The
 639.    URI syntax consists of a sequence of components separated by reserved
 640.    characters, with the first component defining the semantics for the
 641.    remainder of the URI string.
 642. 
 643.    Scheme names consist of a sequence of characters beginning with a
 644.    lower case letter and followed by any combination of lower case
 645.    letters, digits, plus ("+"), period ("."), or hyphen ("-").  For
 646.    resiliency, programs interpreting URI should treat upper case letters
 647.    as equivalent to lower case in scheme names (e.g., allow "HTTP" as
 648.    well as "http").
 649. 
 650.       scheme        = alpha *( alpha | digit | "+" | "-" | "." )
 651. 
 652.    Relative URI references are distinguished from absolute URI in that
 653.    they do not begin with a scheme name.  Instead, the scheme is
 654.    inherited from the base URI, as described in Section 5.2.
 655. 
 656. 3.2. Authority Component
 657. 
 658.    Many URI schemes include a top hierarchical element for a naming
 659.    authority, such that the namespace defined by the remainder of the
 660.    URI is governed by that authority.  This authority component is
 661.    typically defined by an Internet-based server or a scheme-specific
 662.    registry of naming authorities.
 663. 
 664.       authority     = server | reg_name
 665. 
 666.    The authority component is preceded by a double slash "//" and is
 667.    terminated by the next slash "/", question-mark "?", or by the end of
 668.    the URI.  Within the authority component, the characters ";", ":",
 669.    "@", "?", and "/" are reserved.
 670. 
 671. 
 672. 
 673. Berners-Lee, et. al.        Standards Track                    [Page 12]
 674.  


 675. RFC 2396                   URI Generic Syntax                August 1998
 676. 
 677. 
 678.    An authority component is not required for a URI scheme to make use
 679.    of relative references.  A base URI without an authority component
 680.    implies that any relative reference will also be without an authority
 681.    component.
 682. 
 683. 3.2.1. Registry-based Naming Authority
 684. 
 685.    The structure of a registry-based naming authority is specific to the
 686.    URI scheme, but constrained to the allowed characters for an
 687.    authority component.
 688. 
 689.       reg_name      = 1*( unreserved | escaped | "$" | "," |
 690.                           ";" | ":" | "@" | "&" | "=" | "+" )
 691. 
 692. 3.2.2. Server-based Naming Authority
 693. 
 694.    URL schemes that involve the direct use of an IP-based protocol to a
 695.    specified server on the Internet use a common syntax for the server
 696.    component of the URI's scheme-specific data:
 697. 
 698.       @:
 699. 
 700.    where  may consist of a user name and, optionally, scheme-
 701.    specific information about how to gain authorization to access the
 702.    server.  The parts "@" and ":" may be omitted.
 703. 
 704.       server        = [ [ userinfo "@" ] hostport ]
 705. 
 706.    The user information, if present, is followed by a commercial at-sign
 707.    "@".
 708. 
 709.       userinfo      = *( unreserved | escaped |
 710.                          ";" | ":" | "&" | "=" | "+" | "$" | "," )
 711. 
 712.    Some URL schemes use the format "user:password" in the userinfo
 713.    field. This practice is NOT RECOMMENDED, because the passing of
 714.    authentication information in clear text (such as URI) has proven to
 715.    be a security risk in almost every case where it has been used.
 716. 
 717.    The host is a domain name of a network host, or its IPv4 address as a
 718.    set of four decimal digit groups separated by ".".  Literal IPv6
 719.    addresses are not supported.
 720. 
 721.       hostport      = host [ ":" port ]
 722.       host          = hostname | IPv4address
 723.       hostname      = *( domainlabel "." ) toplabel [ "." ]
 724.       domainlabel   = alphanum | alphanum *( alphanum | "-" ) alphanum
 725.       toplabel      = alpha | alpha *( alphanum | "-" ) alphanum
 726. 
 727. 
 728. 
 729. Berners-Lee, et. al.        Standards Track                    [Page 13]
 730.  


 731. RFC 2396                   URI Generic Syntax                August 1998
 732. 
 733. 
 734.       IPv4address   = 1*digit "." 1*digit "." 1*digit "." 1*digit
 735.       port          = *digit
 736. 
 737.    Hostnames take the form described in Section 3 of [RFC1034] and
 738.    Section 2.1 of [RFC1123]: a sequence of domain labels separated by
 739.    ".", each domain label starting and ending with an alphanumeric
 740.    character and possibly also containing "-" characters.  The rightmost
 741.    domain label of a fully qualified domain name will never start with a
 742.    digit, thus syntactically distinguishing domain names from IPv4
 743.    addresses, and may be followed by a single "." if it is necessary to
 744.    distinguish between the complete domain name and any local domain.
 745.    To actually be "Uniform" as a resource locator, a URL hostname should
 746.    be a fully qualified domain name.  In practice, however, the host
 747.    component may be a local domain literal.
 748. 
 749.       Note: A suitable representation for including a literal IPv6
 750.       address as the host part of a URL is desired, but has not yet been
 751.       determined or implemented in practice.
 752. 
 753.    The port is the network port number for the server.  Most schemes
 754.    designate protocols that have a default port number.  Another port
 755.    number may optionally be supplied, in decimal, separated from the
 756.    host by a colon.  If the port is omitted, the default port number is
 757.    assumed.
 758. 
 759. 3.3. Path Component
 760. 
 761.    The path component contains data, specific to the authority (or the
 762.    scheme if there is no authority component), identifying the resource
 763.    within the scope of that scheme and authority.
 764. 
 765.       path          = [ abs_path | opaque_part ]
 766. 
 767.       path_segments = segment *( "/" segment )
 768.       segment       = *pchar *( ";" param )
 769.       param         = *pchar
 770. 
 771.       pchar         = unreserved | escaped |
 772.                       ":" | "@" | "&" | "=" | "+" | "$" | ","
 773. 
 774.    The path may consist of a sequence of path segments separated by a
 775.    single slash "/" character.  Within a path segment, the characters
 776.    "/", ";", "=", and "?" are reserved.  Each path segment may include a
 777.    sequence of parameters, indicated by the semicolon ";" character.
 778.    The parameters are not significant to the parsing of relative
 779.    references.
 780. 
 781. 
 782. 
 783. 
 784. 
 785. Berners-Lee, et. al.        Standards Track                    [Page 14]
 786.  


 787. RFC 2396                   URI Generic Syntax                August 1998
 788. 
 789. 
 790. 3.4. Query Component
 791. 
 792.    The query component is a string of information to be interpreted by
 793.    the resource.
 794. 
 795.       query         = *uric
 796. 
 797.    Within a query component, the characters ";", "/", "?", ":", "@",
 798.    "&", "=", "+", ",", and "$" are reserved.
 799. 
 800. 4. URI References
 801. 
 802.    The term "URI-reference" is used here to denote the common usage of a
 803.    resource identifier.  A URI reference may be absolute or relative,
 804.    and may have additional information attached in the form of a
 805.    fragment identifier.  However, "the URI" that results from such a
 806.    reference includes only the absolute URI after the fragment
 807.    identifier (if any) is removed and after any relative URI is resolved
 808.    to its absolute form.  Although it is possible to limit the
 809.    discussion of URI syntax and semantics to that of the absolute
 810.    result, most usage of URI is within general URI references, and it is
 811.    impossible to obtain the URI from such a reference without also
 812.    parsing the fragment and resolving the relative form.
 813. 
 814.       URI-reference = [ absoluteURI | relativeURI ] [ "#" fragment ]
 815. 
 816.    The syntax for relative URI is a shortened form of that for absolute
 817.    URI, where some prefix of the URI is missing and certain path
 818.    components ("." and "..") have a special meaning when, and only when,
 819.    interpreting a relative path.  The relative URI syntax is defined in
 820.    Section 5.
 821. 
 822. 4.1. Fragment Identifier
 823. 
 824.    When a URI reference is used to perform a retrieval action on the
 825.    identified resource, the optional fragment identifier, separated from
 826.    the URI by a crosshatch ("#") character, consists of additional
 827.    reference information to be interpreted by the user agent after the
 828.    retrieval action has been successfully completed.  As such, it is not
 829.    part of a URI, but is often used in conjunction with a URI.
 830. 
 831.       fragment      = *uric
 832. 
 833.    The semantics of a fragment identifier is a property of the data
 834.    resulting from a retrieval action, regardless of the type of URI used
 835.    in the reference.  Therefore, the format and interpretation of
 836.    fragment identifiers is dependent on the media type [RFC2046] of the
 837.    retrieval result.  The character restrictions described in Section 2
 838. 
 839. 
 840. 
 841. Berners-Lee, et. al.        Standards Track                    [Page 15]
 842.  


 843. RFC 2396                   URI Generic Syntax                August 1998
 844. 
 845. 
 846.    for URI also apply to the fragment in a URI-reference.  Individual
 847.    media types may define additional restrictions or structure within
 848.    the fragment for specifying different types of "partial views" that
 849.    can be identified within that media type.
 850. 
 851.    A fragment identifier is only meaningful when a URI reference is
 852.    intended for retrieval and the result of that retrieval is a document
 853.    for which the identified fragment is consistently defined.
 854. 
 855. 4.2. Same-document References
 856. 
 857.    A URI reference that does not contain a URI is a reference to the
 858.    current document.  In other words, an empty URI reference within a
 859.    document is interpreted as a reference to the start of that document,
 860.    and a reference containing only a fragment identifier is a reference
 861.    to the identified fragment of that document.  Traversal of such a
 862.    reference should not result in an additional retrieval action.
 863.    However, if the URI reference occurs in a context that is always
 864.    intended to result in a new request, as in the case of HTML's FORM
 865.    element, then an empty URI reference represents the base URI of the
 866.    current document and should be replaced by that URI when transformed
 867.    into a request.
 868. 
 869. 4.3. Parsing a URI Reference
 870. 
 871.    A URI reference is typically parsed according to the four main
 872.    components and fragment identifier in order to determine what
 873.    components are present and whether the reference is relative or
 874.    absolute.  The individual components are then parsed for their
 875.    subparts and, if not opaque, to verify their validity.
 876. 
 877.    Although the BNF defines what is allowed in each component, it is
 878.    ambiguous in terms of differentiating between an authority component
 879.    and a path component that begins with two slash characters.  The
 880.    greedy algorithm is used for disambiguation: the left-most matching
 881.    rule soaks up as much of the URI reference string as it is capable of
 882.    matching.  In other words, the authority component wins.
 883. 
 884.    Readers familiar with regular expressions should see Appendix B for a
 885.    concrete parsing example and test oracle.
 886. 
 887. 5. Relative URI References
 888. 
 889.    It is often the case that a group or "tree" of documents has been
 890.    constructed to serve a common purpose; the vast majority of URI in
 891.    these documents point to resources within the tree rather than
 892. 
 893. 
 894. 
 895. 
 896. 
 897. Berners-Lee, et. al.        Standards Track                    [Page 16]
 898.  


 899. RFC 2396                   URI Generic Syntax                August 1998
 900. 
 901. 
 902.    outside of it.  Similarly, documents located at a particular site are
 903.    much more likely to refer to other resources at that site than to
 904.    resources at remote sites.
 905. 
 906.    Relative addressing of URI allows document trees to be partially
 907.    independent of their location and access scheme.  For instance, it is
 908.    possible for a single set of hypertext documents to be simultaneously
 909.    accessible and traversable via each of the "file", "http", and "ftp"
 910.    schemes if the documents refer to each other using relative URI.
 911.    Furthermore, such document trees can be moved, as a whole, without
 912.    changing any of the relative references.  Experience within the WWW
 913.    has demonstrated that the ability to perform relative referencing is
 914.    necessary for the long-term usability of embedded URI.
 915. 
 916.    The syntax for relative URI takes advantage of the  syntax
 917.    of  (Section 3) in order to express a reference that is
 918.    relative to the namespace of another hierarchical URI.
 919. 
 920.       relativeURI   = ( net_path | abs_path | rel_path ) [ "?" query ]
 921. 
 922.    A relative reference beginning with two slash characters is termed a
 923.    network-path reference, as defined by  in Section 3.  Such
 924.    references are rarely used.
 925. 
 926.    A relative reference beginning with a single slash character is
 927.    termed an absolute-path reference, as defined by  in
 928.    Section 3.
 929. 
 930.    A relative reference that does not begin with a scheme name or a
 931.    slash character is termed a relative-path reference.
 932. 
 933.       rel_path      = rel_segment [ abs_path ]
 934. 
 935.       rel_segment   = 1*( unreserved | escaped |
 936.                           ";" | "@" | "&" | "=" | "+" | "$" | "," )
 937. 
 938.    Within a relative-path reference, the complete path segments "." and
 939.    ".." have special meanings: "the current hierarchy level" and "the
 940.    level above this hierarchy level", respectively.  Although this is
 941.    very similar to their use within Unix-based filesystems to indicate
 942.    directory levels, these path components are only considered special
 943.    when resolving a relative-path reference to its absolute form
 944.    (Section 5.2).
 945. 
 946.    Authors should be aware that a path segment which contains a colon
 947.    character cannot be used as the first segment of a relative URI path
 948.    (e.g., "this:that"), because it would be mistaken for a scheme name.
 949. 
 950. 
 951. 
 952. 
 953. Berners-Lee, et. al.        Standards Track                    [Page 17]
 954.  


 955. RFC 2396                   URI Generic Syntax                August 1998
 956. 
 957. 
 958.    It is therefore necessary to precede such segments with other
 959.    segments (e.g., "./this:that") in order for them to be referenced as
 960.    a relative path.
 961. 
 962.    It is not necessary for all URI within a given scheme to be
 963.    restricted to the  syntax, since the hierarchical
 964.    properties of that syntax are only necessary when relative URI are
 965.    used within a particular document.  Documents can only make use of
 966.    relative URI when their base URI fits within the  syntax.
 967.    It is assumed that any document which contains a relative reference
 968.    will also have a base URI that obeys the syntax.  In other words,
 969.    relative URI cannot be used within a document that has an unsuitable
 970.    base URI.
 971. 
 972.    Some URI schemes do not allow a hierarchical syntax matching the
 973.     syntax, and thus cannot use relative references.
 974. 
 975. 5.1. Establishing a Base URI
 976. 
 977.    The term "relative URI" implies that there exists some absolute "base
 978.    URI" against which the relative reference is applied.  Indeed, the
 979.    base URI is necessary to define the semantics of any relative URI
 980.    reference; without it, a relative reference is meaningless.  In order
 981.    for relative URI to be usable within a document, the base URI of that
 982.    document must be known to the parser.
 983. 
 984.    The base URI of a document can be established in one of four ways,
 985.    listed below in order of precedence.  The order of precedence can be
 986.    thought of in terms of layers, where the innermost defined base URI
 987.    has the highest precedence.  This can be visualized graphically as:
 988. 
 989.       .----------------------------------------------------------.
 990.       |  .----------------------------------------------------.  |
 991.       |  |  .----------------------------------------------.  |  |
 992.       |  |  |  .----------------------------------------.  |  |  |
 993.       |  |  |  |  .----------------------------------.  |  |  |  |
 994.       |  |  |  |  |              |  |  |  |  |
 995.       |  |  |  |  `----------------------------------'  |  |  |  |
 996.       |  |  |  | (5.1.1) Base URI embedded in the       |  |  |  |
 997.       |  |  |  |         document's content             |  |  |  |
 998.       |  |  |  `----------------------------------------'  |  |  |
 999.       |  |  | (5.1.2) Base URI of the encapsulating entity |  |  |
1000.       |  |  |         (message, document, or none).        |  |  |
1001.       |  |  `----------------------------------------------'  |  |
1002.       |  | (5.1.3) URI used to retrieve the entity            |  |
1003.       |  `----------------------------------------------------'  |
1004.       | (5.1.4) Default Base URI is application-dependent        |
1005.       `----------------------------------------------------------'
1006. 
1007. 
1008. 
1009. Berners-Lee, et. al.        Standards Track                    [Page 18]
1010.  


1011. RFC 2396                   URI Generic Syntax                August 1998
1012. 
1013. 
1014. 5.1.1. Base URI within Document Content
1015. 
1016.    Within certain document media types, the base URI of the document can
1017.    be embedded within the content itself such that it can be readily
1018.    obtained by a parser.  This can be useful for descriptive documents,
1019.    such as tables of content, which may be transmitted to others through
1020.    protocols other than their usual retrieval context (e.g., E-Mail or
1021.    USENET news).
1022. 
1023.    It is beyond the scope of this document to specify how, for each
1024.    media type, the base URI can be embedded.  It is assumed that user
1025.    agents manipulating such media types will be able to obtain the
1026.    appropriate syntax from that media type's specification.  An example
1027.    of how the base URI can be embedded in the Hypertext Markup Language
1028.    (HTML) [RFC1866] is provided in Appendix D.
1029. 
1030.    A mechanism for embedding the base URI within MIME container types
1031.    (e.g., the message and multipart types) is defined by MHTML
1032.    [RFC2110].  Protocols that do not use the MIME message header syntax,
1033.    but which do allow some form of tagged metainformation to be included
1034.    within messages, may define their own syntax for defining the base
1035.    URI as part of a message.
1036. 
1037. 5.1.2. Base URI from the Encapsulating Entity
1038. 
1039.    If no base URI is embedded, the base URI of a document is defined by
1040.    the document's retrieval context.  For a document that is enclosed
1041.    within another entity (such as a message or another document), the
1042.    retrieval context is that entity; thus, the default base URI of the
1043.    document is the base URI of the entity in which the document is
1044.    encapsulated.
1045. 
1046. 5.1.3. Base URI from the Retrieval URI
1047. 
1048.    If no base URI is embedded and the document is not encapsulated
1049.    within some other entity (e.g., the top level of a composite entity),
1050.    then, if a URI was used to retrieve the base document, that URI shall
1051.    be considered the base URI.  Note that if the retrieval was the
1052.    result of a redirected request, the last URI used (i.e., that which
1053.    resulted in the actual retrieval of the document) is the base URI.
1054. 
1055. 5.1.4. Default Base URI
1056. 
1057.    If none of the conditions described in Sections 5.1.1--5.1.3 apply,
1058.    then the base URI is defined by the context of the application.
1059.    Since this definition is necessarily application-dependent, failing
1060. 
1061. 
1062. 
1063. 
1064. 
1065. Berners-Lee, et. al.        Standards Track                    [Page 19]
1066.  


1067. RFC 2396                   URI Generic Syntax                August 1998
1068. 
1069. 
1070.    to define the base URI using one of the other methods may result in
1071.    the same content being interpreted differently by different types of
1072.    application.
1073. 
1074.    It is the responsibility of the distributor(s) of a document
1075.    containing relative URI to ensure that the base URI for that document
1076.    can be established.  It must be emphasized that relative URI cannot
1077.    be used reliably in situations where the document's base URI is not
1078.    well-defined.
1079. 
1080. 5.2. Resolving Relative References to Absolute Form
1081. 
1082.    This section describes an example algorithm for resolving URI
1083.    references that might be relative to a given base URI.
1084. 
1085.    The base URI is established according to the rules of Section 5.1 and
1086.    parsed into the four main components as described in Section 3.  Note
1087.    that only the scheme component is required to be present in the base
1088.    URI; the other components may be empty or undefined.  A component is
1089.    undefined if its preceding separator does not appear in the URI
1090.    reference; the path component is never undefined, though it may be
1091.    empty.  The base URI's query component is not used by the resolution
1092.    algorithm and may be discarded.
1093. 
1094.    For each URI reference, the following steps are performed in order:
1095. 
1096.    1) The URI reference is parsed into the potential four components and
1097.       fragment identifier, as described in Section 4.3.
1098. 
1099.    2) If the path component is empty and the scheme, authority, and
1100.       query components are undefined, then it is a reference to the
1101.       current document and we are done.  Otherwise, the reference URI's
1102.       query and fragment components are defined as found (or not found)
1103.       within the URI reference and not inherited from the base URI.
1104. 
1105.    3) If the scheme component is defined, indicating that the reference
1106.       starts with a scheme name, then the reference is interpreted as an
1107.       absolute URI and we are done.  Otherwise, the reference URI's
1108.       scheme is inherited from the base URI's scheme component.
1109. 
1110.       Due to a loophole in prior specifications [RFC1630], some parsers
1111.       allow the scheme name to be present in a relative URI if it is the
1112.       same as the base URI scheme.  Unfortunately, this can conflict
1113.       with the correct parsing of non-hierarchical URI.  For backwards
1114.       compatibility, an implementation may work around such references
1115.       by removing the scheme if it matches that of the base URI and the
1116.       scheme is known to always use the  syntax.  The parser
1117. 
1118. 
1119. 
1120. 
1121. Berners-Lee, et. al.        Standards Track                    [Page 20]
1122.  


1123. RFC 2396                   URI Generic Syntax                August 1998
1124. 
1125. 
1126.       can then continue with the steps below for the remainder of the
1127.       reference components.  Validating parsers should mark such a
1128.       misformed relative reference as an error.
1129. 
1130.    4) If the authority component is defined, then the reference is a
1131.       network-path and we skip to step 7.  Otherwise, the reference
1132.       URI's authority is inherited from the base URI's authority
1133.       component, which will also be undefined if the URI scheme does not
1134.       use an authority component.
1135. 
1136.    5) If the path component begins with a slash character ("/"), then
1137.       the reference is an absolute-path and we skip to step 7.
1138. 
1139.    6) If this step is reached, then we are resolving a relative-path
1140.       reference.  The relative path needs to be merged with the base
1141.       URI's path.  Although there are many ways to do this, we will
1142.       describe a simple method using a separate string buffer.
1143. 
1144.       a) All but the last segment of the base URI's path component is
1145.          copied to the buffer.  In other words, any characters after the
1146.          last (right-most) slash character, if any, are excluded.
1147. 
1148.       b) The reference's path component is appended to the buffer
1149.          string.
1150. 
1151.       c) All occurrences of "./", where "." is a complete path segment,
1152.          are removed from the buffer string.
1153. 
1154.       d) If the buffer string ends with "." as a complete path segment,
1155.          that "." is removed.
1156. 
1157.       e) All occurrences of "/../", where  is a
1158.          complete path segment not equal to "..", are removed from the
1159.          buffer string.  Removal of these path segments is performed
1160.          iteratively, removing the leftmost matching pattern on each
1161.          iteration, until no matching pattern remains.
1162. 
1163.       f) If the buffer string ends with "/..", where 
1164.          is a complete path segment not equal to "..", that
1165.          "/.." is removed.
1166. 
1167.       g) If the resulting buffer string still begins with one or more
1168.          complete path segments of "..", then the reference is
1169.          considered to be in error.  Implementations may handle this
1170.          error by retaining these components in the resolved path (i.e.,
1171.          treating them as part of the final URI), by removing them from
1172.          the resolved path (i.e., discarding relative levels above the
1173.          root), or by avoiding traversal of the reference.
1174. 
1175. 
1176. 
1177. Berners-Lee, et. al.        Standards Track                    [Page 21]
1178.  


1179. RFC 2396                   URI Generic Syntax                August 1998
1180. 
1181. 
1182.       h) The remaining buffer string is the reference URI's new path
1183.          component.
1184. 
1185.    7) The resulting URI components, including any inherited from the
1186.       base URI, are recombined to give the absolute form of the URI
1187.       reference.  Using pseudocode, this would be
1188. 
1189.          result = ""
1190. 
1191.          if scheme is defined then
1192.              append scheme to result
1193.              append ":" to result
1194. 
1195.          if authority is defined then
1196.              append "//" to result
1197.              append authority to result
1198. 
1199.          append path to result
1200. 
1201.          if query is defined then
1202.              append "?" to result
1203.              append query to result
1204. 
1205.          if fragment is defined then
1206.              append "#" to result
1207.              append fragment to result
1208. 
1209.          return result
1210. 
1211.       Note that we must be careful to preserve the distinction between a
1212.       component that is undefined, meaning that its separator was not
1213.       present in the reference, and a component that is empty, meaning
1214.       that the separator was present and was immediately followed by the
1215.       next component separator or the end of the reference.
1216. 
1217.    The above algorithm is intended to provide an example by which the
1218.    output of implementations can be tested -- implementation of the
1219.    algorithm itself is not required.  For example, some systems may find
1220.    it more efficient to implement step 6 as a pair of segment stacks
1221.    being merged, rather than as a series of string pattern replacements.
1222. 
1223.       Note: Some WWW client applications will fail to separate the
1224.       reference's query component from its path component before merging
1225.       the base and reference paths in step 6 above.  This may result in
1226.       a loss of information if the query component contains the strings
1227.       "/../" or "/./".
1228. 
1229.    Resolution examples are provided in Appendix C.
1230. 
1231. 
1232. 
1233. Berners-Lee, et. al.        Standards Track                    [Page 22]
1234.  


1235. RFC 2396                   URI Generic Syntax                August 1998
1236. 
1237. 
1238. 6. URI Normalization and Equivalence
1239. 
1240.    In many cases, different URI strings may actually identify the
1241.    identical resource. For example, the host names used in URL are
1242.    actually case insensitive, and the URL  is
1243.    equivalent to . In general, the rules for
1244.    equivalence and definition of a normal form, if any, are scheme
1245.    dependent. When a scheme uses elements of the common syntax, it will
1246.    also use the common syntax equivalence rules, namely that the scheme
1247.    and hostname are case insensitive and a URL with an explicit ":port",
1248.    where the port is the default for the scheme, is equivalent to one
1249.    where the port is elided.
1250. 
1251. 7. Security Considerations
1252. 
1253.    A URI does not in itself pose a security threat.  Users should beware
1254.    that there is no general guarantee that a URL, which at one time
1255.    located a given resource, will continue to do so.  Nor is there any
1256.    guarantee that a URL will not locate a different resource at some
1257.    later point in time, due to the lack of any constraint on how a given
1258.    authority apportions its namespace.  Such a guarantee can only be
1259.    obtained from the person(s) controlling that namespace and the
1260.    resource in question.  A specific URI scheme may include additional
1261.    semantics, such as name persistence, if those semantics are required
1262.    of all naming authorities for that scheme.
1263. 
1264.    It is sometimes possible to construct a URL such that an attempt to
1265.    perform a seemingly harmless, idempotent operation, such as the
1266.    retrieval of an entity associated with the resource, will in fact
1267.    cause a possibly damaging remote operation to occur.  The unsafe URL
1268.    is typically constructed by specifying a port number other than that
1269.    reserved for the network protocol in question.  The client
1270.    unwittingly contacts a site that is in fact running a different
1271.    protocol.  The content of the URL contains instructions that, when
1272.    interpreted according to this other protocol, cause an unexpected
1273.    operation.  An example has been the use of a gopher URL to cause an
1274.    unintended or impersonating message to be sent via a SMTP server.
1275. 
1276.    Caution should be used when using any URL that specifies a port
1277.    number other than the default for the protocol, especially when it is
1278.    a number within the reserved space.
1279. 
1280.    Care should be taken when a URL contains escaped delimiters for a
1281.    given protocol (for example, CR and LF characters for telnet
1282.    protocols) that these are not unescaped before transmission.  This
1283.    might violate the protocol, but avoids the potential for such
1284. 
1285. 
1286. 
1287. 
1288. 
1289. Berners-Lee, et. al.        Standards Track                    [Page 23]
1290.  


1291. RFC 2396                   URI Generic Syntax                August 1998
1292. 
1293. 
1294.    characters to be used to simulate an extra operation or parameter in
1295.    that protocol, which might lead to an unexpected and possibly harmful
1296.    remote operation to be performed.
1297. 
1298.    It is clearly unwise to use a URL that contains a password which is
1299.    intended to be secret. In particular, the use of a password within
1300.    the 'userinfo' component of a URL is strongly disrecommended except
1301.    in those rare cases where the 'password' parameter is intended to be
1302.    public.
1303. 
1304. 8. Acknowledgements
1305. 
1306.    This document was derived from RFC 1738 [RFC1738] and RFC 1808
1307.    [RFC1808]; the acknowledgements in those specifications still apply.
1308.    In addition, contributions by Gisle Aas, Martin Beet, Martin Duerst,
1309.    Jim Gettys, Martijn Koster, Dave Kristol, Daniel LaLiberte, Foteos
1310.    Macrides, James Marshall, Ryan Moats, Keith Moore, and Lauren Wood
1311.    are gratefully acknowledged.
1312. 
1313. 9. References
1314. 
1315.    [RFC2277] Alvestrand, H., "IETF Policy on Character Sets and
1316.              Languages", BCP 18, RFC 2277, January 1998.
1317. 
1318.    [RFC1630] Berners-Lee, T., "Universal Resource Identifiers in WWW: A
1319.              Unifying Syntax for the Expression of Names and Addresses
1320.              of Objects on the Network as used in the World-Wide Web",
1321.              RFC 1630, June 1994.
1322. 
1323.    [RFC1738] Berners-Lee, T., Masinter, L., and M. McCahill, Editors,
1324.              "Uniform Resource Locators (URL)", RFC 1738, December 1994.
1325. 
1326.    [RFC1866] Berners-Lee T., and D. Connolly, "HyperText Markup Language
1327.              Specification -- 2.0", RFC 1866, November 1995.
1328. 
1329.    [RFC1123] Braden, R., Editor, "Requirements for Internet Hosts --
1330.              Application and Support", STD 3, RFC 1123, October 1989.
1331. 
1332.    [RFC822]  Crocker, D., "Standard for the Format of ARPA Internet Text
1333.              Messages", STD 11, RFC 822, August 1982.
1334. 
1335.    [RFC1808] Fielding, R., "Relative Uniform Resource Locators", RFC
1336.              1808, June 1995.
1337. 
1338.    [RFC2046] Freed, N., and N. Borenstein, "Multipurpose Internet Mail
1339.              Extensions (MIME) Part Two: Media Types", RFC 2046,
1340.              November 1996.
1341. 
1342. 
1343. 
1344. 
1345. Berners-Lee, et. al.        Standards Track                    [Page 24]
1346.  


1347. RFC 2396                   URI Generic Syntax                August 1998
1348. 
1349. 
1350.    [RFC1736] Kunze, J., "Functional Recommendations for Internet
1351.              Resource Locators", RFC 1736, February 1995.
1352. 
1353.    [RFC2141] Moats, R., "URN Syntax", RFC 2141, May 1997.
1354. 
1355.    [RFC1034] Mockapetris, P., "Domain Names - Concepts and Facilities",
1356.              STD 13, RFC 1034, November 1987.
1357. 
1358.    [RFC2110] Palme, J., and A. Hopmann, "MIME E-mail Encapsulation of
1359.              Aggregate Documents, such as HTML (MHTML)", RFC 2110, March
1360.              1997.
1361. 
1362.    [RFC1737] Sollins, K., and L. Masinter, "Functional Requirements for
1363.              Uniform Resource Names", RFC 1737, December 1994.
1364. 
1365.    [ASCII]   US-ASCII. "Coded Character Set -- 7-bit American Standard
1366.              Code for Information Interchange", ANSI X3.4-1986.
1367. 
1368.    [UTF-8]   Yergeau, F., "UTF-8, a transformation format of ISO 10646",
1369.              RFC 2279, January 1998.
1370. 
1371. 
1372. 
1373. 
1374. 
1375. 
1376. 
1377. 
1378. 
1379. 
1380. 
1381. 
1382. 
1383. 
1384. 
1385. 
1386. 
1387. 
1388. 
1389. 
1390. 
1391. 
1392. 
1393. 
1394. 
1395. 
1396. 
1397. 
1398. 
1399. 
1400. 
1401. Berners-Lee, et. al.        Standards Track                    [Page 25]
1402.  


1403. RFC 2396                   URI Generic Syntax                August 1998
1404. 
1405. 
1406. 10. Authors' Addresses
1407. 
1408.    Tim Berners-Lee
1409.    World Wide Web Consortium
1410.    MIT Laboratory for Computer Science, NE43-356
1411.    545 Technology Square
1412.    Cambridge, MA 02139
1413. 
1414.    Fax: +1(617)258-8682
1415.    EMail: timbl@w3.org
1416. 
1417. 
1418.    Roy T. Fielding
1419.    Department of Information and Computer Science
1420.    University of California, Irvine
1421.    Irvine, CA  92697-3425
1422. 
1423.    Fax: +1(949)824-1715
1424.    EMail: fielding@ics.uci.edu
1425. 
1426. 
1427.    Larry Masinter
1428.    Xerox PARC
1429.    3333 Coyote Hill Road
1430.    Palo Alto, CA 94034
1431. 
1432.    Fax: +1(415)812-4333
1433.    EMail: masinter@parc.xerox.com
1434. 
1435. 
1436. 
1437. 
1438. 
1439. 
1440. 
1441. 
1442. 
1443. 
1444. 
1445. 
1446. 
1447. 
1448. 
1449. 
1450. 
1451. 
1452. 
1453. 
1454. 
1455. 
1456. 
1457. Berners-Lee, et. al.        Standards Track                    [Page 26]
1458.  


1459. RFC 2396                   URI Generic Syntax                August 1998
1460. 
1461. 
1462. A. Collected BNF for URI
1463. 
1464.       URI-reference = [ absoluteURI | relativeURI ] [ "#" fragment ]
1465.       absoluteURI   = scheme ":" ( hier_part | opaque_part )
1466.       relativeURI   = ( net_path | abs_path | rel_path ) [ "?" query ]
1467. 
1468.       hier_part     = ( net_path | abs_path ) [ "?" query ]
1469.       opaque_part   = uric_no_slash *uric
1470. 
1471.       uric_no_slash = unreserved | escaped | ";" | "?" | ":" | "@" |
1472.                       "&" | "=" | "+" | "$" | ","
1473. 
1474.       net_path      = "//" authority [ abs_path ]
1475.       abs_path      = "/"  path_segments
1476.       rel_path      = rel_segment [ abs_path ]
1477. 
1478.       rel_segment   = 1*( unreserved | escaped |
1479.                           ";" | "@" | "&" | "=" | "+" | "$" | "," )
1480. 
1481.       scheme        = alpha *( alpha | digit | "+" | "-" | "." )
1482. 
1483.       authority     = server | reg_name
1484. 
1485.       reg_name      = 1*( unreserved | escaped | "$" | "," |
1486.                           ";" | ":" | "@" | "&" | "=" | "+" )
1487. 
1488.       server        = [ [ userinfo "@" ] hostport ]
1489.       userinfo      = *( unreserved | escaped |
1490.                          ";" | ":" | "&" | "=" | "+" | "$" | "," )
1491. 
1492.       hostport      = host [ ":" port ]
1493.       host          = hostname | IPv4address
1494.       hostname      = *( domainlabel "." ) toplabel [ "." ]
1495.       domainlabel   = alphanum | alphanum *( alphanum | "-" ) alphanum
1496.       toplabel      = alpha | alpha *( alphanum | "-" ) alphanum
1497.       IPv4address   = 1*digit "." 1*digit "." 1*digit "." 1*digit
1498.       port          = *digit
1499. 
1500.       path          = [ abs_path | opaque_part ]
1501.       path_segments = segment *( "/" segment )
1502.       segment       = *pchar *( ";" param )
1503.       param         = *pchar
1504.       pchar         = unreserved | escaped |
1505.                       ":" | "@" | "&" | "=" | "+" | "$" | ","
1506. 
1507.       query         = *uric
1508. 
1509.       fragment      = *uric
1510. 
1511. 
1512. 
1513. Berners-Lee, et. al.        Standards Track                    [Page 27]
1514.  


1515. RFC 2396                   URI Generic Syntax                August 1998
1516. 
1517. 
1518.       uric          = reserved | unreserved | escaped
1519.       reserved      = ";" | "/" | "?" | ":" | "@" | "&" | "=" | "+" |
1520.                       "$" | ","
1521.       unreserved    = alphanum | mark
1522.       mark          = "-" | "_" | "." | "!" | "~" | "*" | "'" |
1523.                       "(" | ")"
1524. 
1525.       escaped       = "%" hex hex
1526.       hex           = digit | "A" | "B" | "C" | "D" | "E" | "F" |
1527.                               "a" | "b" | "c" | "d" | "e" | "f"
1528. 
1529.       alphanum      = alpha | digit
1530.       alpha         = lowalpha | upalpha
1531. 
1532.       lowalpha = "a" | "b" | "c" | "d" | "e" | "f" | "g" | "h" | "i" |
1533.                  "j" | "k" | "l" | "m" | "n" | "o" | "p" | "q" | "r" |
1534.                  "s" | "t" | "u" | "v" | "w" | "x" | "y" | "z"
1535.       upalpha  = "A" | "B" | "C" | "D" | "E" | "F" | "G" | "H" | "I" |
1536.                  "J" | "K" | "L" | "M" | "N" | "O" | "P" | "Q" | "R" |
1537.                  "S" | "T" | "U" | "V" | "W" | "X" | "Y" | "Z"
1538.       digit    = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" |
1539.                  "8" | "9"
1540. 
1541. 
1542. 
1543. 
1544. 
1545. 
1546. 
1547. 
1548. 
1549. 
1550. 
1551. 
1552. 
1553. 
1554. 
1555. 
1556. 
1557. 
1558. 
1559. 
1560. 
1561. 
1562. 
1563. 
1564. 
1565. 
1566. 
1567. 
1568. 
1569. Berners-Lee, et. al.        Standards Track                    [Page 28]
1570.  


1571. RFC 2396                   URI Generic Syntax                August 1998
1572. 
1573. 
1574. B. Parsing a URI Reference with a Regular Expression
1575. 
1576.    As described in Section 4.3, the generic URI syntax is not sufficient
1577.    to disambiguate the components of some forms of URI.  Since the
1578.    "greedy algorithm" described in that section is identical to the
1579.    disambiguation method used by POSIX regular expressions, it is
1580.    natural and commonplace to use a regular expression for parsing the
1581.    potential four components and fragment identifier of a URI reference.
1582. 
1583.    The following line is the regular expression for breaking-down a URI
1584.    reference into its components.
1585. 
1586.       ^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?
1587.        12            3  4          5       6  7        8 9
1588. 
1589.    The numbers in the second line above are only to assist readability;
1590.    they indicate the reference points for each subexpression (i.e., each
1591.    paired parenthesis).  We refer to the value matched for subexpression
1592.     as $.  For example, matching the above expression to
1593. 
1594.       http://www.ics.uci.edu/pub/ietf/uri/#Related
1595. 
1596.    results in the following subexpression matches:
1597. 
1598.       $1 = http:
1599.       $2 = http
1600.       $3 = //www.ics.uci.edu
1601.       $4 = www.ics.uci.edu
1602.       $5 = /pub/ietf/uri/
1603.       $6 = 
1604.       $7 = 
1605.       $8 = #Related
1606.       $9 = Related
1607. 
1608.    where  indicates that the component is not present, as is
1609.    the case for the query component in the above example.  Therefore, we
1610.    can determine the value of the four components and fragment as
1611. 
1612.       scheme    = $2
1613.       authority = $4
1614.       path      = $5
1615.       query     = $7
1616.       fragment  = $9
1617. 
1618.    and, going in the opposite direction, we can recreate a URI reference
1619.    from its components using the algorithm in step 7 of Section 5.2.
1620. 
1621. 
1622. 
1623. 
1624. 
1625. Berners-Lee, et. al.        Standards Track                    [Page 29]
1626.  


1627. RFC 2396                   URI Generic Syntax                August 1998
1628. 
1629. 
1630. C. Examples of Resolving Relative URI References
1631. 
1632.    Within an object with a well-defined base URI of
1633. 
1634.       http://a/b/c/d;p?q
1635. 
1636.    the relative URI would be resolved as follows:
1637. 
1638. C.1.  Normal Examples
1639. 
1640.       g:h           =  g:h
1641.       g             =  http://a/b/c/g
1642.       ./g           =  http://a/b/c/g
1643.       g/            =  http://a/b/c/g/
1644.       /g            =  http://a/g
1645.       //g           =  http://g
1646.       ?y            =  http://a/b/c/?y
1647.       g?y           =  http://a/b/c/g?y
1648.       #s            =  (current document)#s
1649.       g#s           =  http://a/b/c/g#s
1650.       g?y#s         =  http://a/b/c/g?y#s
1651.       ;x            =  http://a/b/c/;x
1652.       g;x           =  http://a/b/c/g;x
1653.       g;x?y#s       =  http://a/b/c/g;x?y#s
1654.       .             =  http://a/b/c/
1655.       ./            =  http://a/b/c/
1656.       ..            =  http://a/b/
1657.       ../           =  http://a/b/
1658.       ../g          =  http://a/b/g
1659.       ../..         =  http://a/
1660.       ../../        =  http://a/
1661.       ../../g       =  http://a/g
1662. 
1663. C.2.  Abnormal Examples
1664. 
1665.    Although the following abnormal examples are unlikely to occur in
1666.    normal practice, all URI parsers should be capable of resolving them
1667.    consistently.  Each example uses the same base as above.
1668. 
1669.    An empty reference refers to the start of the current document.
1670. 
1671.       <>            =  (current document)
1672. 
1673.    Parsers must be careful in handling the case where there are more
1674.    relative path ".." segments than there are hierarchical levels in the
1675.    base URI's path.  Note that the ".." syntax cannot be used to change
1676.    the authority component of a URI.
1677. 
1678. 
1679. 
1680. 
1681. Berners-Lee, et. al.        Standards Track                    [Page 30]
1682.  


1683. RFC 2396                   URI Generic Syntax                August 1998
1684. 
1685. 
1686.       ../../../g    =  http://a/../g
1687.       ../../../../g =  http://a/../../g
1688. 
1689.    In practice, some implementations strip leading relative symbolic
1690.    elements (".", "..") after applying a relative URI calculation, based
1691.    on the theory that compensating for obvious author errors is better
1692.    than allowing the request to fail.  Thus, the above two references
1693.    will be interpreted as "http://a/g" by some implementations.
1694. 
1695.    Similarly, parsers must avoid treating "." and ".." as special when
1696.    they are not complete components of a relative path.
1697. 
1698.       /./g          =  http://a/./g
1699.       /../g         =  http://a/../g
1700.       g.            =  http://a/b/c/g.
1701.       .g            =  http://a/b/c/.g
1702.       g..           =  http://a/b/c/g..
1703.       ..g           =  http://a/b/c/..g
1704. 
1705.    Less likely are cases where the relative URI uses unnecessary or
1706.    nonsensical forms of the "." and ".." complete path segments.
1707. 
1708.       ./../g        =  http://a/b/g
1709.       ./g/.         =  http://a/b/c/g/
1710.       g/./h         =  http://a/b/c/g/h
1711.       g/../h        =  http://a/b/c/h
1712.       g;x=1/./y     =  http://a/b/c/g;x=1/y
1713.       g;x=1/../y    =  http://a/b/c/y
1714. 
1715.    All client applications remove the query component from the base URI
1716.    before resolving relative URI.  However, some applications fail to
1717.    separate the reference's query and/or fragment components from a
1718.    relative path before merging it with the base path.  This error is
1719.    rarely noticed, since typical usage of a fragment never includes the
1720.    hierarchy ("/") character, and the query component is not normally
1721.    used within relative references.
1722. 
1723.       g?y/./x       =  http://a/b/c/g?y/./x
1724.       g?y/../x      =  http://a/b/c/g?y/../x
1725.       g#s/./x       =  http://a/b/c/g#s/./x
1726.       g#s/../x      =  http://a/b/c/g#s/../x
1727. 
1728. 
1729. 
1730. 
1731. 
1732. 
1733. 
1734. 
1735. 
1736. 
1737. Berners-Lee, et. al.        Standards Track                    [Page 31]
1738.  


1739. RFC 2396                   URI Generic Syntax                August 1998
1740. 
1741. 
1742.    Some parsers allow the scheme name to be present in a relative URI if
1743.    it is the same as the base URI scheme.  This is considered to be a
1744.    loophole in prior specifications of partial URI [RFC1630]. Its use
1745.    should be avoided.
1746. 
1747.       http:g        =  http:g           ; for validating parsers
1748.                     |  http://a/b/c/g   ; for backwards compatibility
1749. 
1750. 
1751. 
1752. 
1753. 
1754. 
1755. 
1756. 
1757. 
1758. 
1759. 
1760. 
1761. 
1762. 
1763. 
1764. 
1765. 
1766. 
1767. 
1768. 
1769. 
1770. 
1771. 
1772. 
1773. 
1774. 
1775. 
1776. 
1777. 
1778. 
1779. 
1780. 
1781. 
1782. 
1783. 
1784. 
1785. 
1786. 
1787. 
1788. 
1789. 
1790. 
1791. 
1792. 
1793. Berners-Lee, et. al.        Standards Track                    [Page 32]
1794.  


1795. RFC 2396                   URI Generic Syntax                August 1998
1796. 
1797. 
1798. D. Embedding the Base URI in HTML documents
1799. 
1800.    It is useful to consider an example of how the base URI of a document
1801.    can be embedded within the document's content.  In this appendix, we
1802.    describe how documents written in the Hypertext Markup Language
1803.    (HTML) [RFC1866] can include an embedded base URI.  This appendix
1804.    does not form a part of the URI specification and should not be
1805.    considered as anything more than a descriptive example.
1806. 
1807.    HTML defines a special element "BASE" which, when present in the
1808.    "HEAD" portion of a document, signals that the parser should use the
1809.    BASE element's "HREF" attribute as the base URI for resolving any
1810.    relative URI.  The "HREF" attribute must be an absolute URI.  Note
1811.    that, in HTML, element and attribute names are case-insensitive.  For
1812.    example:
1813. 
1814.       
1815.       
1816.       An example HTML document
1817.       
1818.       
1819.       ... a hypertext anchor ...
1820.       
1821. 
1822.    A parser reading the example document should interpret the given
1823.    relative URI "../x" as representing the absolute URI
1824. 
1825.       
1826. 
1827.    regardless of the context in which the example document was obtained.
1828. 
1829. 
1830. 
1831. 
1832. 
1833. 
1834. 
1835. 
1836. 
1837. 
1838. 
1839. 
1840. 
1841. 
1842. 
1843. 
1844. 
1845. 
1846. 
1847. 
1848. 
1849. Berners-Lee, et. al.        Standards Track                    [Page 33]
1850.  


1851. RFC 2396                   URI Generic Syntax                August 1998
1852. 
1853. 
1854. E. Recommendations for Delimiting URI in Context
1855. 
1856.    URI are often transmitted through formats that do not provide a clear
1857.    context for their interpretation.  For example, there are many
1858.    occasions when URI are included in plain text; examples include text
1859.    sent in electronic mail, USENET news messages, and, most importantly,
1860.    printed on paper.  In such cases, it is important to be able to
1861.    delimit the URI from the rest of the text, and in particular from
1862.    punctuation marks that might be mistaken for part of the URI.
1863. 
1864.    In practice, URI are delimited in a variety of ways, but usually
1865.    within double-quotes "http://test.com/", angle brackets
1866.    , or just using whitespace
1867. 
1868.                              http://test.com/
1869. 
1870.    These wrappers do not form part of the URI.
1871. 
1872.    In the case where a fragment identifier is associated with a URI
1873.    reference, the fragment would be placed within the brackets as well
1874.    (separated from the URI with a "#" character).
1875. 
1876.    In some cases, extra whitespace (spaces, linebreaks, tabs, etc.) may
1877.    need to be added to break long URI across lines. The whitespace
1878.    should be ignored when extracting the URI.
1879. 
1880.    No whitespace should be introduced after a hyphen ("-") character.
1881.    Because some typesetters and printers may (erroneously) introduce a
1882.    hyphen at the end of line when breaking a line, the interpreter of a
1883.    URI containing a line break immediately after a hyphen should ignore
1884.    all unescaped whitespace around the line break, and should be aware
1885.    that the hyphen may or may not actually be part of the URI.
1886. 
1887.    Using <> angle brackets around each URI is especially recommended as
1888.    a delimiting style for URI that contain whitespace.
1889. 
1890.    The prefix "URL:" (with or without a trailing space) was recommended
1891.    as a way to used to help distinguish a URL from other bracketed
1892.    designators, although this is not common in practice.
1893. 
1894.    For robustness, software that accepts user-typed URI should attempt
1895.    to recognize and strip both delimiters and embedded whitespace.
1896. 
1897.    For example, the text:
1898. 
1899. 
1900. 
1901. 
1902. 
1903. 
1904. 
1905. Berners-Lee, et. al.        Standards Track                    [Page 34]
1906.  


1907. RFC 2396                   URI Generic Syntax                August 1998
1908. 
1909. 
1910.       Yes, Jim, I found it under "http://www.w3.org/Addressing/",
1911.       but you can probably pick it up from .  Note the warning in .
1914. 
1915.    contains the URI references
1916. 
1917.       http://www.w3.org/Addressing/
1918.       ftp://ds.internic.net/rfc/
1919.       http://www.ics.uci.edu/pub/ietf/uri/historical.html#WARNING
1920. 
1921. 
1922. 
1923. 
1924. 
1925. 
1926. 
1927. 
1928. 
1929. 
1930. 
1931. 
1932. 
1933. 
1934. 
1935. 
1936. 
1937. 
1938. 
1939. 
1940. 
1941. 
1942. 
1943. 
1944. 
1945. 
1946. 
1947. 
1948. 
1949. 
1950. 
1951. 
1952. 
1953. 
1954. 
1955. 
1956. 
1957. 
1958. 
1959. 
1960. 
1961. Berners-Lee, et. al.        Standards Track                    [Page 35]
1962.  


1963. RFC 2396                   URI Generic Syntax                August 1998
1964. 
1965. 
1966. F. Abbreviated URLs
1967. 
1968.    The URL syntax was designed for unambiguous reference to network
1969.    resources and extensibility via the URL scheme.  However, as URL
1970.    identification and usage have become commonplace, traditional media
1971.    (television, radio, newspapers, billboards, etc.) have increasingly
1972.    used abbreviated URL references.  That is, a reference consisting of
1973.    only the authority and path portions of the identified resource, such
1974.    as
1975. 
1976.       www.w3.org/Addressing/
1977. 
1978.    or simply the DNS hostname on its own.  Such references are primarily
1979.    intended for human interpretation rather than machine, with the
1980.    assumption that context-based heuristics are sufficient to complete
1981.    the URL (e.g., most hostnames beginning with "www" are likely to have
1982.    a URL prefix of "http://").  Although there is no standard set of
1983.    heuristics for disambiguating abbreviated URL references, many client
1984.    implementations allow them to be entered by the user and
1985.    heuristically resolved.  It should be noted that such heuristics may
1986.    change over time, particularly when new URL schemes are introduced.
1987. 
1988.    Since an abbreviated URL has the same syntax as a relative URL path,
1989.    abbreviated URL references cannot be used in contexts where relative
1990.    URLs are expected.  This limits the use of abbreviated URLs to places
1991.    where there is no defined base URL, such as dialog boxes and off-line
1992.    advertisements.
1993. 
1994. 
1995. 
1996. 
1997. 
1998. 
1999. 
2000. 
2001. 
2002. 
2003. 
2004. 
2005. 
2006. 
2007. 
2008. 
2009. 
2010. 
2011. 
2012. 
2013. 
2014. 
2015. 
2016. 
2017. Berners-Lee, et. al.        Standards Track                    [Page 36]
2018.  


2019. RFC 2396                   URI Generic Syntax                August 1998
2020. 
2021. 
2022. G. Summary of Non-editorial Changes
2023. 
2024. G.1. Additions
2025. 
2026.    Section 4 (URI References) was added to stem the confusion regarding
2027.    "what is a URI" and how to describe fragment identifiers given that
2028.    they are not part of the URI, but are part of the URI syntax and
2029.    parsing concerns.  In addition, it provides a reference definition
2030.    for use by other IETF specifications (HTML, HTTP, etc.) that have
2031.    previously attempted to redefine the URI syntax in order to account
2032.    for the presence of fragment identifiers in URI references.
2033. 
2034.    Section 2.4 was rewritten to clarify a number of misinterpretations
2035.    and to leave room for fully internationalized URI.
2036. 
2037.    Appendix F on abbreviated URLs was added to describe the shortened
2038.    references often seen on television and magazine advertisements and
2039.    explain why they are not used in other contexts.
2040. 
2041. G.2. Modifications from both RFC 1738 and RFC 1808
2042. 
2043.    Changed to URI syntax instead of just URL.
2044. 
2045.    Confusion regarding the terms "character encoding", the URI
2046.    "character set", and the escaping of characters with %
2047.    equivalents has (hopefully) been reduced.  Many of the BNF rule names
2048.    regarding the character sets have been changed to more accurately
2049.    describe their purpose and to encompass all "characters" rather than
2050.    just US-ASCII octets.  Unless otherwise noted here, these
2051.    modifications do not affect the URI syntax.
2052. 
2053.    Both RFC 1738 and RFC 1808 refer to the "reserved" set of characters
2054.    as if URI-interpreting software were limited to a single set of
2055.    characters with a reserved purpose (i.e., as meaning something other
2056.    than the data to which the characters correspond), and that this set
2057.    was fixed by the URI scheme.  However, this has not been true in
2058.    practice; any character that is interpreted differently when it is
2059.    escaped is, in effect, reserved.  Furthermore, the interpreting
2060.    engine on a HTTP server is often dependent on the resource, not just
2061.    the URI scheme.  The description of reserved characters has been
2062.    changed accordingly.
2063. 
2064.    The plus "+", dollar "$", and comma "," characters have been added to
2065.    those in the "reserved" set, since they are treated as reserved
2066.    within the query component.
2067. 
2068. 
2069. 
2070. 
2071. 
2072. 
2073. Berners-Lee, et. al.        Standards Track                    [Page 37]
2074.  


2075. RFC 2396                   URI Generic Syntax                August 1998
2076. 
2077. 
2078.    The tilde "~" character was added to those in the "unreserved" set,
2079.    since it is extensively used on the Internet in spite of the
2080.    difficulty to transcribe it with some keyboards.
2081. 
2082.    The syntax for URI scheme has been changed to require that all
2083.    schemes begin with an alpha character.
2084. 
2085.    The "user:password" form in the previous BNF was changed to a
2086.    "userinfo" token, and the possibility that it might be
2087.    "user:password" made scheme specific. In particular, the use of
2088.    passwords in the clear is not even suggested by the syntax.
2089. 
2090.    The question-mark "?" character was removed from the set of allowed
2091.    characters for the userinfo in the authority component, since testing
2092.    showed that many applications treat it as reserved for separating the
2093.    query component from the rest of the URI.
2094. 
2095.    The semicolon ";" character was added to those stated as being
2096.    reserved within the authority component, since several new schemes
2097.    are using it as a separator within userinfo to indicate the type of
2098.    user authentication.
2099. 
2100.    RFC 1738 specified that the path was separated from the authority
2101.    portion of a URI by a slash.  RFC 1808 followed suit, but with a
2102.    fudge of carrying around the separator as a "prefix" in order to
2103.    describe the parsing algorithm.  RFC 1630 never had this problem,
2104.    since it considered the slash to be part of the path.  In writing
2105.    this specification, it was found to be impossible to accurately
2106.    describe and retain the difference between the two URI
2107.          and   
2108.    without either considering the slash to be part of the path (as
2109.    corresponds to actual practice) or creating a separate component just
2110.    to hold that slash.  We chose the former.
2111. 
2112. G.3. Modifications from RFC 1738
2113. 
2114.    The definition of specific URL schemes and their scheme-specific
2115.    syntax and semantics has been moved to separate documents.
2116. 
2117.    The URL host was defined as a fully-qualified domain name.  However,
2118.    many URLs are used without fully-qualified domain names (in contexts
2119.    for which the full qualification is not necessary), without any host
2120.    (as in some file URLs), or with a host of "localhost".
2121. 
2122.    The URL port is now *digit instead of 1*digit, since systems are
2123.    expected to handle the case where the ":" separator between host and
2124.    port is supplied without a port.
2125. 
2126. 
2127. 
2128. 
2129. Berners-Lee, et. al.        Standards Track                    [Page 38]
2130.  


2131. RFC 2396                   URI Generic Syntax                August 1998
2132. 
2133. 
2134.    The recommendations for delimiting URI in context (Appendix E) have
2135.    been adjusted to reflect current practice.
2136. 
2137. G.4. Modifications from RFC 1808
2138. 
2139.    RFC 1808 (Section 4) defined an empty URL reference (a reference
2140.    containing nothing aside from the fragment identifier) as being a
2141.    reference to the base URL.  Unfortunately, that definition could be
2142.    interpreted, upon selection of such a reference, as a new retrieval
2143.    action on that resource.  Since the normal intent of such references
2144.    is for the user agent to change its view of the current document to
2145.    the beginning of the specified fragment within that document, not to
2146.    make an additional request of the resource, a description of how to
2147.    correctly interpret an empty reference has been added in Section 4.
2148. 
2149.    The description of the mythical Base header field has been replaced
2150.    with a reference to the Content-Location header field defined by
2151.    MHTML [RFC2110].
2152. 
2153.    RFC 1808 described various schemes as either having or not having the
2154.    properties of the generic URI syntax.  However, the only requirement
2155.    is that the particular document containing the relative references
2156.    have a base URI that abides by the generic URI syntax, regardless of
2157.    the URI scheme, so the associated description has been updated to
2158.    reflect that.
2159. 
2160.    The BNF term  has been replaced with , since the
2161.    latter more accurately describes its use and purpose.  Likewise, the
2162.    authority is no longer restricted to the IP server syntax.
2163. 
2164.    Extensive testing of current client applications demonstrated that
2165.    the majority of deployed systems do not use the ";" character to
2166.    indicate trailing parameter information, and that the presence of a
2167.    semicolon in a path segment does not affect the relative parsing of
2168.    that segment.  Therefore, parameters have been removed as a separate
2169.    component and may now appear in any path segment.  Their influence
2170.    has been removed from the algorithm for resolving a relative URI
2171.    reference.  The resolution examples in Appendix C have been modified
2172.    to reflect this change.
2173. 
2174.    Implementations are now allowed to work around misformed relative
2175.    references that are prefixed by the same scheme as the base URI, but
2176.    only for schemes known to use the  syntax.
2177. 
2178. 
2179. 
2180. 
2181. 
2182. 
2183. 
2184. 
2185. Berners-Lee, et. al.        Standards Track                    [Page 39]
2186.  


2187. RFC 2396                   URI Generic Syntax                August 1998
2188. 
2189. 
2190. H.  Full Copyright Statement
2191. 
2192.    Copyright (C) The Internet Society (1998).  All Rights Reserved.
2193. 
2194.    This document and translations of it may be copied and furnished to
2195.    others, and derivative works that comment on or otherwise explain it
2196.    or assist in its implementation may be prepared, copied, published
2197.    and distributed, in whole or in part, without restriction of any
2198.    kind, provided that the above copyright notice and this paragraph are
2199.    included on all such copies and derivative works.  However, this
2200.    document itself may not be modified in any way, such as by removing
2201.    the copyright notice or references to the Internet Society or other
2202.    Internet organizations, except as needed for the purpose of
2203.    developing Internet standards in which case the procedures for
2204.    copyrights defined in the Internet Standards process must be
2205.    followed, or as required to translate it into languages other than
2206.    English.
2207. 
2208.    The limited permissions granted above are perpetual and will not be
2209.    revoked by the Internet Society or its successors or assigns.
2210. 
2211.    This document and the information contained herein is provided on an
2212.    "AS IS" basis and THE INTERNET SOCIETY AND THE INTERNET ENGINEERING
2213.    TASK FORCE DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
2214.    BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION
2215.    HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF
2216.    MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
2217. 
2218. 
2219. 
2220. 
2221. 
2222. 
2223. 
2224. 
2225. 
2226. 
2227. 
2228. 
2229. 
2230. 
2231. 
2232. 
2233. 
2234. 
2235. 
2236. 
2237. 
2238. 
2239. 
2240. 
2241. Berners-Lee, et. al.        Standards Track                    [Page 40]
2242.  


2243. 
2244.