Network Working Group                                     T. Berners-Lee
Request for Comments: 2396                                       MIT/LCS
Updates: 1808, 1738                                          R. Fielding
Category: Standards Track                                    U.C. Irvine
                                                             L. Masinter
                                                       Xerox Corporation
                                                             August 1998
        
Network Working Group                                     T. Berners-Lee
Request for Comments: 2396                                       MIT/LCS
Updates: 1808, 1738                                          R. Fielding
Category: Standards Track                                    U.C. Irvine
                                                             L. Masinter
                                                       Xerox Corporation
                                                             August 1998
        

Uniform Resource Identifiers (URI): Generic Syntax

统一资源标识符(URI):通用语法

Status of this Memo

本备忘录的状况

This document specifies an Internet standards track protocol for the Internet community, and requests discussion and suggestions for improvements. Please refer to the current edition of the "Internet Official Protocol Standards" (STD 1) for the standardization state and status of this protocol. Distribution of this memo is unlimited.

本文件规定了互联网社区的互联网标准跟踪协议,并要求进行讨论和提出改进建议。有关本协议的标准化状态和状态,请参考当前版本的“互联网官方协议标准”(STD 1)。本备忘录的分发不受限制。

Copyright Notice

版权公告

Copyright (C) The Internet Society (1998). All Rights Reserved.

版权所有(C)互联网协会(1998年)。版权所有。

IESG Note

IESG注释

This paper describes a "superset" of operations that can be applied to URI. It consists of both a grammar and a description of basic functionality for URI. To understand what is a valid URI, both the grammar and the associated description have to be studied. Some of the functionality described is not applicable to all URI schemes, and some operations are only possible when certain media types are retrieved using the URI, regardless of the scheme used.

本文描述了可应用于URI的操作的“超集”。它包括URI的语法和基本功能的描述。为了理解什么是有效的URI,必须研究语法和相关的描述。所描述的某些功能不适用于所有URI方案,并且只有在使用URI检索某些媒体类型时,才可能执行某些操作,而不管所使用的方案如何。

Abstract

摘要

A Uniform Resource Identifier (URI) is a compact string of characters for identifying an abstract or physical resource. This document defines the generic syntax of URI, including both absolute and relative forms, and guidelines for their use; it revises and replaces the generic definitions in RFC 1738 and RFC 1808.

统一资源标识符(URI)是用于标识抽象资源或物理资源的紧凑字符串。本文档定义了URI的通用语法,包括绝对和相对形式,以及它们的使用指南;修订并替换RFC 1738和RFC 1808中的通用定义。

This document defines a grammar that is a superset of all valid URI, such that an implementation can parse the common components of a URI reference without knowing the scheme-specific requirements of every possible identifier type. This document does not define a generative grammar for URI; that task will be performed by the individual specifications of each URI scheme.

本文档定义了一个语法,它是所有有效URI的超集,因此实现可以解析URI引用的公共组件,而不需要知道每个可能标识符类型的特定于方案的要求。本文档未定义URI的生成语法;该任务将由每个URI方案的单独规范执行。

1. Introduction
1. 介绍

Uniform Resource Identifiers (URI) provide a simple and extensible means for identifying a resource. This specification of URI syntax and semantics is derived from concepts introduced by the World Wide Web global information initiative, whose use of such objects dates from 1990 and is described in "Universal Resource Identifiers in WWW" [RFC1630]. The specification of URI is designed to meet the recommendations laid out in "Functional Recommendations for Internet Resource Locators" [RFC1736] and "Functional Requirements for Uniform Resource Names" [RFC1737].

统一资源标识符(URI)为识别资源提供了一种简单且可扩展的方法。URI语法和语义的规范源自万维网全球信息倡议(World Wide Web global information initiative)引入的概念,其对此类对象的使用始于1990年,并在“WWW中的通用资源标识符”[RFC1630]中进行了描述。URI规范旨在满足“Internet资源定位器的功能建议”[RFC1736]和“统一资源名称的功能要求”[RFC1737]中提出的建议。

This document updates and merges "Uniform Resource Locators" [RFC1738] and "Relative Uniform Resource Locators" [RFC1808] in order to define a single, generic syntax for all URI. It excludes those portions of RFC 1738 that defined the specific syntax of individual URL schemes; those portions will be updated as separate documents, as will the process for registration of new URI schemes. This document does not discuss the issues and recommendation for dealing with characters outside of the US-ASCII character set [ASCII]; those recommendations are discussed in a separate document.

本文档更新并合并了“统一资源定位器”[RFC1738]和“相对统一资源定位器”[RFC1808],以便为所有URI定义单一的通用语法。它不包括RFC 1738中定义单个URL方案特定语法的部分;这些部分将作为单独的文件更新,新URI方案的注册过程也将更新。本文件不讨论处理US-ASCII字符集[ASCII]以外字符的问题和建议;这些建议在另一份文件中讨论。

All significant changes from the prior RFCs are noted in Appendix G.

附录G中记录了先前RFC的所有重大变化。

1.1 Overview of URI
1.1 URI概述

URI are characterized by the following definitions:

URI具有以下定义的特征:

Uniform Uniformity provides several benefits: it allows different types of resource identifiers to be used in the same context, even when the mechanisms used to access those resources may differ; it allows uniform semantic interpretation of common syntactic conventions across different types of resource identifiers; it allows introduction of new types of resource identifiers without interfering with the way that existing identifiers are used; and, it allows the identifiers to be reused in many different contexts, thus permitting new applications or protocols to leverage a pre-existing, large, and widely-used set of resource identifiers.

统一性提供了几个好处:它允许在同一上下文中使用不同类型的资源标识符,即使用于访问这些资源的机制可能不同;它允许跨不同类型的资源标识符对常见语法约定进行统一的语义解释;它允许引入新类型的资源标识符,而不干扰现有标识符的使用方式;而且,它允许在许多不同的上下文中重用标识符,从而允许新的应用程序或协议利用预先存在的、大型且广泛使用的资源标识符集。

Resource A resource can be anything that has identity. Familiar examples include an electronic document, an image, a service (e.g., "today's weather report for Los Angeles"), and a collection of other resources. Not all resources are network "retrievable"; e.g., human beings, corporations, and bound books in a library can also be considered resources.

资源资源可以是任何具有标识的资源。熟悉的例子包括电子文档、图像、服务(例如,“今日洛杉矶天气报告”)和其他资源的集合。并非所有资源都是网络“可检索的”;e、 例如,图书馆中的人、公司和装订书籍也可以被视为资源。

         The resource is the conceptual mapping to an entity or set of
         entities, not necessarily the entity which corresponds to that
         mapping at any particular instance in time.  Thus, a resource
         can remain constant even when its content---the entities to
         which it currently corresponds---changes over time, provided
         that the conceptual mapping is not changed in the process.
        
         The resource is the conceptual mapping to an entity or set of
         entities, not necessarily the entity which corresponds to that
         mapping at any particular instance in time.  Thus, a resource
         can remain constant even when its content---the entities to
         which it currently corresponds---changes over time, provided
         that the conceptual mapping is not changed in the process.
        

Identifier An identifier is an object that can act as a reference to something that has identity. In the case of URI, the object is a sequence of characters with a restricted syntax.

标识符标识符是一个对象,可以作为对具有标识的对象的引用。对于URI,对象是一个具有受限语法的字符序列。

Having identified a resource, a system may perform a variety of operations on the resource, as might be characterized by such words as `access', `update', `replace', or `find attributes'.

识别资源后,系统可以对资源执行各种操作,其特征可能是“访问”、“更新”、“替换”或“查找属性”。

1.2. URI, URL, and URN
1.2. URI、URL和URN

A URI can be further classified as a locator, a name, or both. The term "Uniform Resource Locator" (URL) refers to the subset of URI that identify resources via a representation of their primary access mechanism (e.g., their network "location"), rather than identifying the resource by name or by some other attribute(s) of that resource. The term "Uniform Resource Name" (URN) refers to the subset of URI that are required to remain globally unique and persistent even when the resource ceases to exist or becomes unavailable.

URI可以进一步分类为定位器、名称或两者。术语“统一资源定位器”(URL)是指URI的子集,其通过资源的主要访问机制(例如,其网络“位置”)的表示来识别资源,而不是通过名称或该资源的某些其他属性来识别资源。术语“统一资源名”(URN)是指URI的子集,即使资源不再存在或变得不可用,这些URI也需要保持全局唯一性和持久性。

The URI scheme (Section 3.1) defines the namespace of the URI, and thus may further restrict the syntax and semantics of identifiers using that scheme. This specification defines those elements of the URI syntax that are either required of all URI schemes or are common to many URI schemes. It thus defines the syntax and semantics that are needed to implement a scheme-independent parsing mechanism for URI references, such that the scheme-dependent handling of a URI can be postponed until the scheme-dependent semantics are needed. We use the term URL below when describing syntax or semantics that only apply to locators.

URI方案(第3.1节)定义了URI的名称空间,因此可能进一步限制使用该方案的标识符的语法和语义。本规范定义了所有URI方案所需或许多URI方案所共有的URI语法元素。因此,它定义了实现URI引用的独立于方案的解析机制所需的语法和语义,这样URI的依赖于方案的处理可以推迟到需要依赖于方案的语义为止。在描述仅适用于定位器的语法或语义时,我们使用下面的术语URL。

Although many URL schemes are named after protocols, this does not imply that the only way to access the URL's resource is via the named protocol. Gateways, proxies, caches, and name resolution services might be used to access some resources, independent of the protocol of their origin, and the resolution of some URL may require the use of more than one protocol (e.g., both DNS and HTTP are typically used to access an "http" URL's resource when it can't be found in a local cache).

尽管许多URL方案是以协议命名的,但这并不意味着访问URL资源的唯一方法是通过命名协议。网关、代理、缓存和名称解析服务可用于访问某些资源,独立于其来源的协议,并且某些URL的解析可能需要使用多个协议(例如,当在本地缓存中找不到“HTTP”URL的资源时,DNS和HTTP通常用于访问该URL的资源)。

A URN differs from a URL in that it's primary purpose is persistent labeling of a resource with an identifier. That identifier is drawn from one of a set of defined namespaces, each of which has its own set name structure and assignment procedures. The "urn" scheme has been reserved to establish the requirements for a standardized URN namespace, as defined in "URN Syntax" [RFC2141] and its related specifications.

URN与URL的不同之处在于,它的主要用途是使用标识符持久标记资源。该标识符来自一组已定义名称空间中的一个,每个名称空间都有自己的集名结构和赋值过程。保留“urn”方案是为了确定标准化urn名称空间的要求,如“urn语法”[RFC2141]及其相关规范中所定义。

Most of the examples in this specification demonstrate URL, since they allow the most varied use of the syntax and often have a hierarchical namespace. A parser of the URI syntax is capable of parsing both URL and URN references as a generic URI; once the scheme is determined, the scheme-specific parsing can be performed on the generic URI components. In other words, the URI syntax is a superset of the syntax of all URI schemes.

本规范中的大多数示例都演示了URL,因为它们允许最多样化的语法使用,并且通常具有分层名称空间。URI语法的解析器能够将URL和URN引用解析为通用URI;一旦确定了方案,就可以对通用URI组件执行特定于方案的解析。换句话说,URI语法是所有URI方案语法的超集。

1.3. Example URI
1.3. 示例URI

The following examples illustrate URI that are in common use.

以下示例说明了常用的URI。

   ftp://ftp.is.co.za/rfc/rfc1808.txt
      -- ftp scheme for File Transfer Protocol services
        
   ftp://ftp.is.co.za/rfc/rfc1808.txt
      -- ftp scheme for File Transfer Protocol services
        
   gopher://spinaltap.micro.umn.edu/00/Weather/California/Los%20Angeles
      -- gopher scheme for Gopher and Gopher+ Protocol services
        
   gopher://spinaltap.micro.umn.edu/00/Weather/California/Los%20Angeles
      -- gopher scheme for Gopher and Gopher+ Protocol services
        
   http://www.math.uio.no/faq/compression-faq/part1.html
      -- http scheme for Hypertext Transfer Protocol services
        
   http://www.math.uio.no/faq/compression-faq/part1.html
      -- http scheme for Hypertext Transfer Protocol services
        

mailto:mduerst@ifi.unizh.ch -- mailto scheme for electronic mail addresses

邮寄地址:mduerst@ifi.unizh.ch--电子邮件地址的mailto方案

news:comp.infosystems.www.servers.unix -- news scheme for USENET news groups and articles

新闻:comp.infosystems.www.servers.unix--USENET新闻组和文章的新闻方案

   telnet://melvyl.ucop.edu/
      -- telnet scheme for interactive services via the TELNET Protocol
        
   telnet://melvyl.ucop.edu/
      -- telnet scheme for interactive services via the TELNET Protocol
        
1.4. Hierarchical URI and Relative Forms
1.4. 层次URI和相关形式

An absolute identifier refers to a resource independent of the context in which the identifier is used. In contrast, a relative identifier refers to a resource by describing the difference within a hierarchical namespace between the current context and an absolute identifier of the resource.

绝对标识符是指独立于使用标识符的上下文的资源。相反,相对标识符通过描述当前上下文和资源的绝对标识符之间的层次命名空间中的差异来引用资源。

Some URI schemes support a hierarchical naming system, where the hierarchy of the name is denoted by a "/" delimiter separating the components in the scheme. This document defines a scheme-independent `relative' form of URI reference that can be used in conjunction with a `base' URI (of a hierarchical scheme) to produce another URI. The syntax of hierarchical URI is described in Section 3; the relative URI calculation is described in Section 5.

一些URI方案支持分层命名系统,其中名称的层次由分隔方案中组件的“/”分隔符表示。本文档定义了一种独立于方案的“相对”形式的URI引用,可与“基本”URI(层次结构方案的)结合使用以生成另一个URI。第3节描述了层次URI的语法;第5节描述了相对URI计算。

1.5. URI Transcribability
1.5. URI可转录性

The URI syntax was designed with global transcribability as one of its main concerns. A URI is a sequence of characters from a very limited set, i.e. the letters of the basic Latin alphabet, digits, and a few special characters. A URI may be represented in a variety of ways: e.g., ink on paper, pixels on a screen, or a sequence of octets in a coded character set. The interpretation of a URI depends only on the characters used and not how those characters are represented in a network protocol.

URI语法的设计主要考虑全局可转录性。URI是一组非常有限的字符,即基本拉丁字母表的字母、数字和一些特殊字符。URI可以多种方式表示:例如,纸上的墨水、屏幕上的像素或编码字符集中的八位字节序列。URI的解释仅取决于所使用的字符,而不取决于这些字符在网络协议中的表示方式。

The goal of transcribability can be described by a simple scenario. Imagine two colleagues, Sam and Kim, sitting in a pub at an international conference and exchanging research ideas. Sam asks Kim for a location to get more information, so Kim writes the URI for the research site on a napkin. Upon returning home, Sam takes out the napkin and types the URI into a computer, which then retrieves the information to which Kim referred.

可转录性的目标可以用一个简单的场景来描述。想象一下,萨姆和金姆这两位同事在一个国际会议上坐在酒吧里,交换研究想法。Sam向Kim询问获取更多信息的位置,因此Kim将研究站点的URI写在餐巾纸上。回到家后,山姆拿出餐巾,将URI输入计算机,然后计算机检索Kim提到的信息。

There are several design concerns revealed by the scenario:

该场景揭示了几个设计问题:

o A URI is a sequence of characters, which is not always represented as a sequence of octets.

o URI是一个字符序列,并不总是表示为八位字节序列。

o A URI may be transcribed from a non-network source, and thus should consist of characters that are most likely to be able to be typed into a computer, within the constraints imposed by keyboards (and related input devices) across languages and locales.

o URI可以从非网络源转录,因此应该由最有可能输入计算机的字符组成,在键盘(和相关输入设备)跨语言和地区施加的限制范围内。

o A URI often needs to be remembered by people, and it is easier for people to remember a URI when it consists of meaningful components.

o URI通常需要被人们记住,当URI由有意义的组件组成时,人们更容易记住URI。

These design concerns are not always in alignment. For example, it is often the case that the most meaningful name for a URI component would require characters that cannot be typed into some systems. The ability to transcribe the resource identifier from one medium to another was considered more important than having its URI consist of the most meaningful of components. In local and regional contexts

这些设计问题并不总是一致的。例如,通常情况下,URI组件最有意义的名称需要无法在某些系统中键入的字符。将资源标识符从一种媒体转录到另一种媒体的能力被认为比其URI由最有意义的组件组成更重要。在地方和区域范围内

and with improving technology, users might benefit from being able to use a wider range of characters; such use is not defined in this document.

随着技术的进步,用户可能会受益于能够使用更广泛的字符;本文件中未定义此类用途。

1.6. Syntax Notation and Common Elements
1.6. 语法符号和公共元素

This document uses two conventions to describe and define the syntax for URI. The first, called the layout form, is a general description of the order of components and component separators, as in

本文档使用两种约定来描述和定义URI的语法。第一种称为布局形式,是组件和组件分隔符顺序的一般说明,如中所示

      <first>/<second>;<third>?<fourth>
        
      <first>/<second>;<third>?<fourth>
        

The component names are enclosed in angle-brackets and any characters outside angle-brackets are literal separators. Whitespace should be ignored. These descriptions are used informally and do not define the syntax requirements.

组件名称用尖括号括起来,尖括号外的任何字符都是文字分隔符。空白应该被忽略。这些描述是非正式使用的,没有定义语法要求。

The second convention is a BNF-like grammar, used to define the formal URI syntax. The grammar is that of [RFC822], except that "|" is used to designate alternatives. Briefly, rules are separated from definitions by an equal "=", indentation is used to continue a rule definition over more than one line, literals are quoted with "", parentheses "(" and ")" are used to group elements, optional elements are enclosed in "[" and "]" brackets, and elements may be preceded with <n>* to designate n or more repetitions of the following element; n defaults to 0.

第二个约定是类似BNF的语法,用于定义正式的URI语法。语法与[RFC822]相同,只是“|”用于指定备选方案。简单地说,规则与定义之间用相等的“=”分隔,缩进用于在多行上继续规则定义,文字用“”引用,圆括号(“and”)用于对元素进行分组,可选元素用“[”和“]”括号括起来,元素前面可加上<n>*以指定下列元素的n个或多个重复;n默认为0。

Unlike many specifications that use a BNF-like grammar to define the bytes (octets) allowed by a protocol, the URI grammar is defined in terms of characters. Each literal in the grammar corresponds to the character it represents, rather than to the octet encoding of that character in any particular coded character set. How a URI is represented in terms of bits and bytes on the wire is dependent upon the character encoding of the protocol used to transport it, or the charset of the document which contains it.

与许多使用类似BNF的语法定义协议允许的字节(八位字节)的规范不同,URI语法是根据字符定义的。语法中的每个文字对应于它所表示的字符,而不是任何特定编码字符集中该字符的八位编码。URI在线路上以位和字节表示的方式取决于用于传输它的协议的字符编码,或者包含它的文档的字符集。

The following definitions are common to many elements:

以下定义对许多元素都是通用的:

alpha = lowalpha | upalpha

α=低α|上α

      lowalpha = "a" | "b" | "c" | "d" | "e" | "f" | "g" | "h" | "i" |
                 "j" | "k" | "l" | "m" | "n" | "o" | "p" | "q" | "r" |
                 "s" | "t" | "u" | "v" | "w" | "x" | "y" | "z"
        
      lowalpha = "a" | "b" | "c" | "d" | "e" | "f" | "g" | "h" | "i" |
                 "j" | "k" | "l" | "m" | "n" | "o" | "p" | "q" | "r" |
                 "s" | "t" | "u" | "v" | "w" | "x" | "y" | "z"
        
      upalpha  = "A" | "B" | "C" | "D" | "E" | "F" | "G" | "H" | "I" |
                 "J" | "K" | "L" | "M" | "N" | "O" | "P" | "Q" | "R" |
                 "S" | "T" | "U" | "V" | "W" | "X" | "Y" | "Z"
        
      upalpha  = "A" | "B" | "C" | "D" | "E" | "F" | "G" | "H" | "I" |
                 "J" | "K" | "L" | "M" | "N" | "O" | "P" | "Q" | "R" |
                 "S" | "T" | "U" | "V" | "W" | "X" | "Y" | "Z"
        
      digit    = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" |
                 "8" | "9"
        
      digit    = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" |
                 "8" | "9"
        

alphanum = alpha | digit

alphanum=α|位

The complete URI syntax is collected in Appendix A.

完整的URI语法收集在附录A中。

2. URI Characters and Escape Sequences
2. URI字符和转义序列

URI consist of a restricted set of characters, primarily chosen to aid transcribability and usability both in computer systems and in non-computer communications. Characters used conventionally as delimiters around URI were excluded. The restricted set of characters consists of digits, letters, and a few graphic symbols were chosen from those common to most of the character encodings and input facilities available to Internet users.

URI由一组有限的字符组成,主要用于帮助计算机系统和非计算机通信中的可转录性和可用性。传统上用作URI周围分隔符的字符被排除在外。受限制的字符集由数字、字母和一些图形符号组成,这些符号是从互联网用户可使用的大多数字符编码和输入设备的常见符号中选择的。

uric = reserved | unreserved | escaped

尿酸=保留的|未保留的|转义的

Within a URI, characters are either used as delimiters, or to represent strings of data (octets) within the delimited portions. Octets are either represented directly by a character (using the US-ASCII character for that octet [ASCII]) or by an escape encoding. This representation is elaborated below.

在URI中,字符要么用作分隔符,要么表示分隔部分中的数据字符串(八位字节)。八位字节可以直接由字符(使用该八位字节的US-ASCII字符[ASCII])表示,也可以通过转义编码表示。下文详细阐述了这一表述。

2.1 URI and non-ASCII characters
2.1 URI和非ASCII字符

The relationship between URI and characters has been a source of confusion for characters that are not part of US-ASCII. To describe the relationship, it is useful to distinguish between a "character" (as a distinguishable semantic entity) and an "octet" (an 8-bit byte). There are two mappings, one from URI characters to octets, and a second from octets to original characters:

URI和字符之间的关系一直是不属于US-ASCII的字符混淆的根源。为了描述这种关系,区分“字符”(作为可区分的语义实体)和“八位字节”(8位字节)是很有用的。有两种映射,一种是从URI字符到八位字节的映射,另一种是从八位字节到原始字符的映射:

URI character sequence->octet sequence->original character sequence

URI字符序列->八位字节序列->原始字符序列

A URI is represented as a sequence of characters, not as a sequence of octets. That is because URI might be "transported" by means that are not through a computer network, e.g., printed on paper, read over the radio, etc.

URI表示为字符序列,而不是八位字节序列。这是因为URI可能是通过非计算机网络的方式“传输”的,例如打印在纸上、通过无线电读取等。

A URI scheme may define a mapping from URI characters to octets; whether this is done depends on the scheme. Commonly, within a delimited component of a URI, a sequence of characters may be used to represent a sequence of octets. For example, the character "a" represents the octet 97 (decimal), while the character sequence "%", "0", "a" represents the octet 10 (decimal).

URI方案可以定义从URI字符到八位字节的映射;是否这样做取决于方案。通常,在URI的分隔组件中,可以使用字符序列来表示八位字节序列。例如,字符“a”表示八位字节97(十进制),而字符序列“%”、“0”、“a”表示八位字节10(十进制)。

There is a second translation for some resources: the sequence of octets defined by a component of the URI is subsequently used to represent a sequence of characters. A 'charset' defines this mapping. There are many charsets in use in Internet protocols. For example, UTF-8 [UTF-8] defines a mapping from sequences of octets to sequences of characters in the repertoire of ISO 10646.

有些资源还有第二种翻译:URI组件定义的八位字节序列随后用于表示字符序列。“字符集”定义了此映射。Internet协议中使用了许多字符集。例如,UTF-8[UTF-8]定义了从八位字节序列到ISO10646指令集中字符序列的映射。

In the simplest case, the original character sequence contains only characters that are defined in US-ASCII, and the two levels of mapping are simple and easily invertible: each 'original character' is represented as the octet for the US-ASCII code for it, which is, in turn, represented as either the US-ASCII character, or else the "%" escape sequence for that octet.

在最简单的情况下,原始字符序列只包含在US-ASCII中定义的字符,并且两个级别的映射简单且容易反转:每个“原始字符”表示为其US-ASCII代码的八位字节,反过来表示为US-ASCII字符或“%”那个八位组的转义序列。

For original character sequences that contain non-ASCII characters, however, the situation is more difficult. Internet protocols that transmit octet sequences intended to represent character sequences are expected to provide some way of identifying the charset used, if there might be more than one [RFC2277]. However, there is currently no provision within the generic URI syntax to accomplish this identification. An individual URI scheme may require a single charset, define a default charset, or provide a way to indicate the charset used.

但是,对于包含非ASCII字符的原始字符序列,情况更为困难。如果可能有多个字符集[RFC2277],则传输用于表示字符序列的八位字节序列的互联网协议有望提供某种识别所用字符集的方法。但是,通用URI语法中目前没有实现此标识的规定。单个URI方案可能需要单个字符集、定义默认字符集或提供指示所用字符集的方法。

It is expected that a systematic treatment of character encoding within URI will be developed as a future modification of this specification.

作为本规范的未来修改,预计将开发URI中字符编码的系统处理。

2.2. Reserved Characters
2.2. 保留字符

Many URI include components consisting of or delimited by, certain special characters. These characters are called "reserved", since their usage within the URI component is limited to their reserved purpose. If the data for a URI component would conflict with the reserved purpose, then the conflicting data must be escaped before forming the URI.

许多URI包含由某些特殊字符组成或由某些特殊字符分隔的组件。这些字符称为“保留字符”,因为它们在URI组件中的使用仅限于保留用途。如果URI组件的数据与保留目的冲突,则必须在形成URI之前转义冲突的数据。

      reserved    = ";" | "/" | "?" | ":" | "@" | "&" | "=" | "+" |
                    "$" | ","
        
      reserved    = ";" | "/" | "?" | ":" | "@" | "&" | "=" | "+" |
                    "$" | ","
        

The "reserved" syntax class above refers to those characters that are allowed within a URI, but which may not be allowed within a particular component of the generic URI syntax; they are used as delimiters of the components described in Section 3.

上面的“保留”语法类是指URI中允许的字符,但在通用URI语法的特定组件中可能不允许的字符;它们用作第3节所述组件的分隔符。

Characters in the "reserved" set are not reserved in all contexts. The set of characters actually reserved within any given URI component is defined by that component. In general, a character is reserved if the semantics of the URI changes if the character is replaced with its escaped US-ASCII encoding.

“保留”集中的字符并非在所有上下文中都保留。任何给定URI组件中实际保留的字符集由该组件定义。通常,如果用转义的US-ASCII编码替换某个字符,则URI的语义会发生变化,则该字符将被保留。

2.3. Unreserved Characters
2.3. 无保留字符

Data characters that are allowed in a URI but do not have a reserved purpose are called unreserved. These include upper and lower case letters, decimal digits, and a limited set of punctuation marks and symbols.

URI中允许但没有保留用途的数据字符称为unreserved。其中包括大写和小写字母、十进制数字以及一组有限的标点符号和符号。

unreserved = alphanum | mark

无保留=字母数|标记

      mark        = "-" | "_" | "." | "!" | "~" | "*" | "'" | "(" | ")"
        
      mark        = "-" | "_" | "." | "!" | "~" | "*" | "'" | "(" | ")"
        

Unreserved characters can be escaped without changing the semantics of the URI, but this should not be done unless the URI is being used in a context that does not allow the unescaped character to appear.

可以在不更改URI语义的情况下转义未保留的字符,但除非在不允许未转义字符出现的上下文中使用URI,否则不应这样做。

2.4. Escape Sequences
2.4. 逃逸序列

Data must be escaped if it does not have a representation using an unreserved character; this includes data that does not correspond to a printable character of the US-ASCII coded character set, or that corresponds to any US-ASCII character that is disallowed, as explained below.

如果数据没有使用无保留字符的表示,则必须对其进行转义;这包括与US-ASCII编码字符集的可打印字符不对应的数据,或与任何不允许的US-ASCII字符对应的数据,如下所述。

2.4.1. Escaped Encoding
2.4.1. 转义编码

An escaped octet is encoded as a character triplet, consisting of the percent character "%" followed by the two hexadecimal digits representing the octet code. For example, "%20" is the escaped encoding for the US-ASCII space character.

转义八位字节编码为字符三元组,由百分比字符“%”和表示八位字节代码的两个十六进制数字组成。例如,“%20”是US-ASCII空格字符的转义编码。

      escaped     = "%" hex hex
      hex         = digit | "A" | "B" | "C" | "D" | "E" | "F" |
                            "a" | "b" | "c" | "d" | "e" | "f"
        
      escaped     = "%" hex hex
      hex         = digit | "A" | "B" | "C" | "D" | "E" | "F" |
                            "a" | "b" | "c" | "d" | "e" | "f"
        
2.4.2. When to Escape and Unescape
2.4.2. 什么时候逃走

A URI is always in an "escaped" form, since escaping or unescaping a completed URI might change its semantics. Normally, the only time escape encodings can safely be made is when the URI is being created from its component parts; each component may have its own set of characters that are reserved, so only the mechanism responsible for generating or interpreting that component can determine whether or

URI总是以“转义”形式出现,因为转义或取消转义已完成的URI可能会改变其语义。通常,安全地进行转义编码的唯一时间是从其组件创建URI时;每个组件可能都有自己的保留字符集,因此只有负责生成或解释该组件的机制才能确定

not escaping a character will change its semantics. Likewise, a URI must be separated into its components before the escaped characters within those components can be safely decoded.

不转义字符将更改其语义。类似地,URI必须被分离为其组件,然后才能安全地解码这些组件中的转义字符。

In some cases, data that could be represented by an unreserved character may appear escaped; for example, some of the unreserved "mark" characters are automatically escaped by some systems. If the given URI scheme defines a canonicalization algorithm, then unreserved characters may be unescaped according to that algorithm. For example, "%7e" is sometimes used instead of "~" in an http URL path, but the two are equivalent for an http URL.

在某些情况下,可以由无保留字符表示的数据可能会出现转义;例如,某些系统会自动转义某些未保留的“标记”字符。如果给定的URI方案定义了规范化算法,则可以根据该算法取消对未保留字符的替换。例如,在http URL路径中,有时使用“%7e”代替“~”,但对于http URL,这两者是等效的。

Because the percent "%" character always has the reserved purpose of being the escape indicator, it must be escaped as "%25" in order to be used as data within a URI. Implementers should be careful not to escape or unescape the same string more than once, since unescaping an already unescaped string might lead to misinterpreting a percent data character as another escaped character, or vice versa in the case of escaping an already escaped string.

由于百分比“%”字符始终具有作为转义指示符的保留用途,因此必须将其转义为“%25”才能用作URI中的数据。实现人员应注意不要多次转义或取消转义同一字符串,因为取消转义已未转义的字符串可能会导致将百分比数据字符误解为另一个转义字符,或者在转义已转义字符串的情况下,反之亦然。

2.4.3. Excluded US-ASCII Characters
2.4.3. 排除的US-ASCII字符

Although they are disallowed within the URI syntax, we include here a description of those US-ASCII characters that have been excluded and the reasons for their exclusion.

尽管URI语法中不允许使用这些字符,但我们在这里介绍了已排除的US-ASCII字符以及排除这些字符的原因。

The control characters in the US-ASCII coded character set are not used within a URI, both because they are non-printable and because they are likely to be misinterpreted by some control mechanisms.

US-ASCII编码字符集中的控制字符不在URI中使用,这既是因为它们不可打印,也是因为它们可能被某些控制机制误解。

   control     = <US-ASCII coded characters 00-1F and 7F hexadecimal>
        
   control     = <US-ASCII coded characters 00-1F and 7F hexadecimal>
        

The space character is excluded because significant spaces may disappear and insignificant spaces may be introduced when URI are transcribed or typeset or subjected to the treatment of word-processing programs. Whitespace is also used to delimit URI in many contexts.

空格字符被排除在外,因为当URI被转录、排版或接受字处理程序处理时,有效空格可能消失,而不重要空格可能被引入。在许多上下文中,空白也用于分隔URI。

   space       = <US-ASCII coded character 20 hexadecimal>
        
   space       = <US-ASCII coded character 20 hexadecimal>
        

The angle-bracket "<" and ">" and double-quote (") characters are excluded because they are often used as the delimiters around URI in text documents and protocol fields. The character "#" is excluded because it is used to delimit a URI from a fragment identifier in URI references (Section 4). The percent character "%" is excluded because it is used for the encoding of escaped characters.

角括号“<”和“>”以及双引号(“)字符被排除在外,因为它们通常用作文本文档和协议字段中URI的分隔符。字符“#”被排除在外,因为它用于从URI引用中的片段标识符中分隔URI(第4节)。百分比字符“%“”被排除,因为它用于对转义字符进行编码。

   delims      = "<" | ">" | "#" | "%" | <">
        
   delims      = "<" | ">" | "#" | "%" | <">
        

Other characters are excluded because gateways and other transport agents are known to sometimes modify such characters, or they are used as delimiters.

其他字符被排除在外,因为已知网关和其他传输代理有时会修改这些字符,或者它们被用作分隔符。

   unwise      = "{" | "}" | "|" | "\" | "^" | "[" | "]" | "`"
        
   unwise      = "{" | "}" | "|" | "\" | "^" | "[" | "]" | "`"
        

Data corresponding to excluded characters must be escaped in order to be properly represented within a URI.

必须对与排除字符对应的数据进行转义,以便在URI中正确表示。

3. URI Syntactic Components
3. URI语法组件

The URI syntax is dependent upon the scheme. In general, absolute URI are written as follows:

URI语法取决于方案。一般来说,绝对URI的编写方式如下:

      <scheme>:<scheme-specific-part>
        
      <scheme>:<scheme-specific-part>
        

An absolute URI contains the name of the scheme being used (<scheme>) followed by a colon (":") and then a string (the <scheme-specific-part>) whose interpretation depends on the scheme.

绝对URI包含正在使用的方案的名称(<scheme>),后跟冒号(:),然后是一个字符串(<scheme-specific part>),其解释取决于方案。

The URI syntax does not require that the scheme-specific-part have any general structure or set of semantics which is common among all URI. However, a subset of URI do share a common syntax for representing hierarchical relationships within the namespace. This "generic URI" syntax consists of a sequence of four main components:

URI语法不要求特定于方案的部分具有所有URI中通用的任何通用结构或语义集。然而,URI的一个子集确实共享用于表示名称空间内的层次关系的公共语法。此“通用URI”语法由四个主要组件组成:

      <scheme>://<authority><path>?<query>
        
      <scheme>://<authority><path>?<query>
        

each of which, except <scheme>, may be absent from a particular URI. For example, some URI schemes do not allow an <authority> component, and others do not use a <query> component.

除了<scheme>,其中的每一个都可能不在特定URI中。例如,一些URI方案不允许使用<authority>组件,而其他URI方案不使用<query>组件。

absoluteURI = scheme ":" ( hier_part | opaque_part )

绝对值=方案“:”(hier_部分|不透明部分)

URI that are hierarchical in nature use the slash "/" character for separating hierarchical components. For some file systems, a "/" character (used to denote the hierarchical structure of a URI) is the delimiter used to construct a file name hierarchy, and thus the URI path will look similar to a file pathname. This does NOT imply that the resource is a file or that the URI maps to an actual filesystem pathname.

本质上是分层的URI使用斜杠“/”字符分隔分层组件。对于某些文件系统,一个“/”字符(用于表示URI的层次结构)是用于构造文件名层次结构的分隔符,因此URI路径看起来类似于文件路径名。这并不意味着资源是一个文件或URI映射到实际的文件系统路径名。

      hier_part     = ( net_path | abs_path ) [ "?" query ]
        
      hier_part     = ( net_path | abs_path ) [ "?" query ]
        
      net_path      = "//" authority [ abs_path ]
        
      net_path      = "//" authority [ abs_path ]
        

abs_path = "/" path_segments

abs_path=“/”路径_段

URI that do not make use of the slash "/" character for separating hierarchical components are considered opaque by the generic URI parser.

一般URI解析器认为,不使用斜杠“/”字符分隔层次结构组件的URI是不透明的。

opaque_part = uric_no_slash *uric

不透明部分=尿酸\无\斜线*尿酸

      uric_no_slash = unreserved | escaped | ";" | "?" | ":" | "@" |
                      "&" | "=" | "+" | "$" | ","
        
      uric_no_slash = unreserved | escaped | ";" | "?" | ":" | "@" |
                      "&" | "=" | "+" | "$" | ","
        

We use the term <path> to refer to both the <abs_path> and <opaque_part> constructs, since they are mutually exclusive for any given URI and can be parsed as a single component.

我们使用术语<path>来指代<abs_path>和<opaque_part>构造,因为它们对于任何给定URI都是互斥的,并且可以作为单个组件进行解析。

3.1. Scheme Component
3.1. 方案组成部分

Just as there are many different methods of access to resources, there are a variety of schemes for identifying such resources. The URI syntax consists of a sequence of components separated by reserved characters, with the first component defining the semantics for the remainder of the URI string.

正如有许多不同的访问资源的方法一样,也有各种各样的识别此类资源的方案。URI语法由一系列由保留字符分隔的组件组成,第一个组件定义URI字符串其余部分的语义。

Scheme names consist of a sequence of characters beginning with a lower case letter and followed by any combination of lower case letters, digits, plus ("+"), period ("."), or hyphen ("-"). For resiliency, programs interpreting URI should treat upper case letters as equivalent to lower case in scheme names (e.g., allow "HTTP" as well as "http").

方案名称由一系列字符组成,这些字符以小写字母开头,后跟小写字母、数字、加号(“+”)、句点(“.”)或连字符(“-”)的任意组合。对于弹性,解释URI的程序应该将大写字母视为方案名称中的小写字母(例如,允许“HTTP”和“HTTP”)。

      scheme        = alpha *( alpha | digit | "+" | "-" | "." )
        
      scheme        = alpha *( alpha | digit | "+" | "-" | "." )
        

Relative URI references are distinguished from absolute URI in that they do not begin with a scheme name. Instead, the scheme is inherited from the base URI, as described in Section 5.2.

相对URI引用与绝对URI的区别在于它们不以方案名称开头。相反,该方案是从基本URI继承的,如第5.2节所述。

3.2. Authority Component
3.2. 权限组件

Many URI schemes include a top hierarchical element for a naming authority, such that the namespace defined by the remainder of the URI is governed by that authority. This authority component is typically defined by an Internet-based server or a scheme-specific registry of naming authorities.

许多URI方案包括命名机构的顶级层次元素,这样URI的其余部分定义的名称空间就由该机构管理。此权限组件通常由基于Internet的服务器或特定于方案的命名权限注册表定义。

authority = server | reg_name

权限=服务器|注册|名称

The authority component is preceded by a double slash "//" and is terminated by the next slash "/", question-mark "?", or by the end of the URI. Within the authority component, the characters ";", ":", "@", "?", and "/" are reserved.

授权组件前面有一个双斜杠“/”,并以下一个斜杠“/”、问号“?”或URI结尾终止。在authority组件中,保留字符“;”、“:”、“@”、“?”和“/”。

An authority component is not required for a URI scheme to make use of relative references. A base URI without an authority component implies that any relative reference will also be without an authority component.

URI方案不需要权限组件来使用相对引用。没有权限组件的基本URI意味着任何相对引用也将没有权限组件。

3.2.1. Registry-based Naming Authority
3.2.1. 基于注册表的命名机构

The structure of a registry-based naming authority is specific to the URI scheme, but constrained to the allowed characters for an authority component.

基于注册表的命名机构的结构特定于URI方案,但仅限于授权组件允许的字符。

      reg_name      = 1*( unreserved | escaped | "$" | "," |
                          ";" | ":" | "@" | "&" | "=" | "+" )
        
      reg_name      = 1*( unreserved | escaped | "$" | "," |
                          ";" | ":" | "@" | "&" | "=" | "+" )
        
3.2.2. Server-based Naming Authority
3.2.2. 基于服务器的命名机构

URL schemes that involve the direct use of an IP-based protocol to a specified server on the Internet use a common syntax for the server component of the URI's scheme-specific data:

涉及对Internet上指定服务器直接使用基于IP的协议的URL方案对URI方案特定数据的服务器组件使用通用语法:

      <userinfo>@<host>:<port>
        
      <userinfo>@<host>:<port>
        

where <userinfo> may consist of a user name and, optionally, scheme-specific information about how to gain authorization to access the server. The parts "<userinfo>@" and ":<port>" may be omitted.

其中,<userinfo>可能包括用户名和(可选)有关如何获得访问服务器的授权的特定于方案的信息。可以省略部分“<userinfo>@”和“:<port>”。

      server        = [ [ userinfo "@" ] hostport ]
        
      server        = [ [ userinfo "@" ] hostport ]
        

The user information, if present, is followed by a commercial at-sign "@".

用户信息(如有)后面会有一个广告符号“@”。

      userinfo      = *( unreserved | escaped |
                         ";" | ":" | "&" | "=" | "+" | "$" | "," )
        
      userinfo      = *( unreserved | escaped |
                         ";" | ":" | "&" | "=" | "+" | "$" | "," )
        

Some URL schemes use the format "user:password" in the userinfo field. This practice is NOT RECOMMENDED, because the passing of authentication information in clear text (such as URI) has proven to be a security risk in almost every case where it has been used.

一些URL方案在userinfo字段中使用“user:password”格式。不建议采用这种做法,因为在几乎所有使用过明文(如URI)的情况下,以明文形式传递身份验证信息都会带来安全风险。

The host is a domain name of a network host, or its IPv4 address as a set of four decimal digit groups separated by ".". Literal IPv6 addresses are not supported.

主机是网络主机的域名,或其IPv4地址,由四个十进制数字组组成,以“.”分隔。不支持文本IPv6地址。

      hostport      = host [ ":" port ]
      host          = hostname | IPv4address
      hostname      = *( domainlabel "." ) toplabel [ "." ]
      domainlabel   = alphanum | alphanum *( alphanum | "-" ) alphanum
      toplabel      = alpha | alpha *( alphanum | "-" ) alphanum
        
      hostport      = host [ ":" port ]
      host          = hostname | IPv4address
      hostname      = *( domainlabel "." ) toplabel [ "." ]
      domainlabel   = alphanum | alphanum *( alphanum | "-" ) alphanum
      toplabel      = alpha | alpha *( alphanum | "-" ) alphanum
        
      IPv4address   = 1*digit "." 1*digit "." 1*digit "." 1*digit
      port          = *digit
        
      IPv4address   = 1*digit "." 1*digit "." 1*digit "." 1*digit
      port          = *digit
        

Hostnames take the form described in Section 3 of [RFC1034] and Section 2.1 of [RFC1123]: a sequence of domain labels separated by ".", each domain label starting and ending with an alphanumeric character and possibly also containing "-" characters. The rightmost domain label of a fully qualified domain name will never start with a digit, thus syntactically distinguishing domain names from IPv4 addresses, and may be followed by a single "." if it is necessary to distinguish between the complete domain name and any local domain. To actually be "Uniform" as a resource locator, a URL hostname should be a fully qualified domain name. In practice, however, the host component may be a local domain literal.

主机名采用[RFC1034]第3节和[RFC1123]第2.1节中所述的形式:由“.”分隔的一系列域标签,每个域标签以字母数字字符开头和结尾,可能还包含“-”字符。完全限定域名的最右边的域名标签永远不会以数字开头,因此从语法上区分域名和IPv4地址,如果有必要区分完整域名和任何本地域名,则可以后跟一个“.”。要真正成为“统一”的资源定位器,URL主机名应该是完全限定的域名。然而,在实践中,主机组件可能是本地域文本。

Note: A suitable representation for including a literal IPv6 address as the host part of a URL is desired, but has not yet been determined or implemented in practice.

注意:需要一个合适的表示,将文字IPv6地址作为URL的主机部分,但尚未在实践中确定或实现。

The port is the network port number for the server. Most schemes designate protocols that have a default port number. Another port number may optionally be supplied, in decimal, separated from the host by a colon. If the port is omitted, the default port number is assumed.

端口是服务器的网络端口号。大多数方案指定具有默认端口号的协议。可以选择提供另一个端口号,以十进制表示,并用冒号与主机分隔。如果省略端口,则假定默认端口号。

3.3. Path Component
3.3. 路径组件

The path component contains data, specific to the authority (or the scheme if there is no authority component), identifying the resource within the scope of that scheme and authority.

路径组件包含特定于权限(如果没有权限组件,则为方案)的数据,用于标识该方案和权限范围内的资源。

      path          = [ abs_path | opaque_part ]
        
      path          = [ abs_path | opaque_part ]
        
      path_segments = segment *( "/" segment )
      segment       = *pchar *( ";" param )
      param         = *pchar
        
      path_segments = segment *( "/" segment )
      segment       = *pchar *( ";" param )
      param         = *pchar
        
      pchar         = unreserved | escaped |
                      ":" | "@" | "&" | "=" | "+" | "$" | ","
        
      pchar         = unreserved | escaped |
                      ":" | "@" | "&" | "=" | "+" | "$" | ","
        

The path may consist of a sequence of path segments separated by a single slash "/" character. Within a path segment, the characters "/", ";", "=", and "?" are reserved. Each path segment may include a sequence of parameters, indicated by the semicolon ";" character. The parameters are not significant to the parsing of relative references.

路径可以由一系列由单个斜杠“/”字符分隔的路径段组成。在路径段中,保留字符“/”、“;”、“=”和“?”。每个路径段可能包括一系列参数,由分号“;”字符表示。这些参数对于解析相对引用并不重要。

3.4. Query Component
3.4. 查询组件

The query component is a string of information to be interpreted by the resource.

查询组件是由资源解释的一组信息。

      query         = *uric
        
      query         = *uric
        

Within a query component, the characters ";", "/", "?", ":", "@", "&", "=", "+", ",", and "$" are reserved.

在查询组件中,保留字符“;”、“/”、“?”、“:”、“@”、“&”、“=”、“+”、“、”和“$”。

4. URI References
4. URI引用

The term "URI-reference" is used here to denote the common usage of a resource identifier. A URI reference may be absolute or relative, and may have additional information attached in the form of a fragment identifier. However, "the URI" that results from such a reference includes only the absolute URI after the fragment identifier (if any) is removed and after any relative URI is resolved to its absolute form. Although it is possible to limit the discussion of URI syntax and semantics to that of the absolute result, most usage of URI is within general URI references, and it is impossible to obtain the URI from such a reference without also parsing the fragment and resolving the relative form.

这里使用术语“URI引用”来表示资源标识符的常见用法。URI引用可以是绝对的,也可以是相对的,并且可以以片段标识符的形式附加附加信息。然而,从这样一个引用中得到的“URI”只包括在片段标识符(如果有的话)被删除之后以及在任何相对URI被解析为其绝对形式之后的绝对URI。尽管可以将URI语法和语义的讨论限制在绝对结果的讨论范围内,但URI的大多数用法都是在一般URI引用中使用的,并且如果不解析片段并解析相对形式,就不可能从此类引用中获取URI。

      URI-reference = [ absoluteURI | relativeURI ] [ "#" fragment ]
        
      URI-reference = [ absoluteURI | relativeURI ] [ "#" fragment ]
        

The syntax for relative URI is a shortened form of that for absolute URI, where some prefix of the URI is missing and certain path components ("." and "..") have a special meaning when, and only when, interpreting a relative path. The relative URI syntax is defined in Section 5.

相对URI的语法是绝对URI的缩写形式,其中缺少URI的某些前缀,并且某些路径组件(“.”和“.”)在解释相对路径时(且仅在解释相对路径时)具有特殊含义。第5节定义了相对URI语法。

4.1. Fragment Identifier
4.1. 片段标识符

When a URI reference is used to perform a retrieval action on the identified resource, the optional fragment identifier, separated from the URI by a crosshatch ("#") character, consists of additional reference information to be interpreted by the user agent after the retrieval action has been successfully completed. As such, it is not part of a URI, but is often used in conjunction with a URI.

当URI引用用于对已标识的资源执行检索操作时,可选的片段标识符(通过交叉线(#)字符与URI分隔)由用户代理在检索操作成功完成后解释的附加引用信息组成。因此,它不是URI的一部分,但通常与URI结合使用。

      fragment      = *uric
        
      fragment      = *uric
        

The semantics of a fragment identifier is a property of the data resulting from a retrieval action, regardless of the type of URI used in the reference. Therefore, the format and interpretation of fragment identifiers is dependent on the media type [RFC2046] of the retrieval result. The character restrictions described in Section 2

片段标识符的语义是由检索操作产生的数据的属性,与引用中使用的URI类型无关。因此,片段标识符的格式和解释取决于检索结果的媒体类型[RFC2046]。第2节中描述的字符限制

for URI also apply to the fragment in a URI-reference. Individual media types may define additional restrictions or structure within the fragment for specifying different types of "partial views" that can be identified within that media type.

for URI也适用于URI引用中的片段。单个媒体类型可在片段内定义附加限制或结构,以指定可在该媒体类型内识别的不同类型的“局部视图”。

A fragment identifier is only meaningful when a URI reference is intended for retrieval and the result of that retrieval is a document for which the identified fragment is consistently defined.

片段标识符只有在URI引用用于检索且检索结果是一致定义了已识别片段的文档时才有意义。

4.2. Same-document References
4.2. 相同的文件参考

A URI reference that does not contain a URI is a reference to the current document. In other words, an empty URI reference within a document is interpreted as a reference to the start of that document, and a reference containing only a fragment identifier is a reference to the identified fragment of that document. Traversal of such a reference should not result in an additional retrieval action. However, if the URI reference occurs in a context that is always intended to result in a new request, as in the case of HTML's FORM element, then an empty URI reference represents the base URI of the current document and should be replaced by that URI when transformed into a request.

不包含URI的URI引用是对当前文档的引用。换句话说,文档中的空URI引用被解释为对该文档开头的引用,而仅包含片段标识符的引用则是对该文档已标识片段的引用。遍历此类引用不应导致额外的检索操作。但是,如果URI引用发生在总是希望产生新请求的上下文中,如HTML的表单元素,则空URI引用表示当前文档的基本URI,并且在转换为请求时应替换为该URI。

4.3. Parsing a URI Reference
4.3. 解析URI引用

A URI reference is typically parsed according to the four main components and fragment identifier in order to determine what components are present and whether the reference is relative or absolute. The individual components are then parsed for their subparts and, if not opaque, to verify their validity.

URI引用通常根据四个主要组件和片段标识符进行解析,以确定存在哪些组件以及引用是相对的还是绝对的。然后分析各个组件的子部分,如果不是不透明的,则验证其有效性。

Although the BNF defines what is allowed in each component, it is ambiguous in terms of differentiating between an authority component and a path component that begins with two slash characters. The greedy algorithm is used for disambiguation: the left-most matching rule soaks up as much of the URI reference string as it is capable of matching. In other words, the authority component wins.

尽管BNF定义了每个组件中允许的内容,但在区分权限组件和以两个斜杠字符开头的路径组件方面是不明确的。贪婪算法用于消除歧义:最左边的匹配规则吸收了尽可能多的URI引用字符串,因为它能够进行匹配。换句话说,授权组件获胜。

Readers familiar with regular expressions should see Appendix B for a concrete parsing example and test oracle.

熟悉正则表达式的读者应参阅附录B,了解具体的解析示例和测试oracle。

5. Relative URI References
5. 相对URI引用

It is often the case that a group or "tree" of documents has been constructed to serve a common purpose; the vast majority of URI in these documents point to resources within the tree rather than

通常情况下,构建一组或“树”文档是为了达到一个共同的目的;这些文档中的绝大多数URI都指向树中的资源,而不是

outside of it. Similarly, documents located at a particular site are much more likely to refer to other resources at that site than to resources at remote sites.

在它之外。类似地,位于特定站点的文档更可能引用该站点的其他资源,而不是远程站点的资源。

Relative addressing of URI allows document trees to be partially independent of their location and access scheme. For instance, it is possible for a single set of hypertext documents to be simultaneously accessible and traversable via each of the "file", "http", and "ftp" schemes if the documents refer to each other using relative URI. Furthermore, such document trees can be moved, as a whole, without changing any of the relative references. Experience within the WWW has demonstrated that the ability to perform relative referencing is necessary for the long-term usability of embedded URI.

URI的相对寻址允许文档树部分独立于它们的位置和访问方案。例如,如果一组超文本文档使用相对URI相互引用,则可以通过“文件”、“http”和“ftp”方案中的每一个同时访问和遍历它们。此外,这些文档树可以作为一个整体进行移动,而无需更改任何相对引用。WWW内的经验表明,执行相对引用的能力对于嵌入式URI的长期可用性是必要的。

The syntax for relative URI takes advantage of the <hier_part> syntax of <absoluteURI> (Section 3) in order to express a reference that is relative to the namespace of another hierarchical URI.

相对URI的语法利用了<absoluteURI>(第3节)的<hier_part>语法,以表示相对于另一层次URI的命名空间的引用。

      relativeURI   = ( net_path | abs_path | rel_path ) [ "?" query ]
        
      relativeURI   = ( net_path | abs_path | rel_path ) [ "?" query ]
        

A relative reference beginning with two slash characters is termed a network-path reference, as defined by <net_path> in Section 3. Such references are rarely used.

以两个斜杠字符开头的相对参考称为网络路径参考,如第3节中的<net_path>所定义。这样的引用很少使用。

A relative reference beginning with a single slash character is termed an absolute-path reference, as defined by <abs_path> in Section 3.

以单个斜杠字符开头的相对参考称为绝对路径参考,如第3节中的<abs_path>所定义。

A relative reference that does not begin with a scheme name or a slash character is termed a relative-path reference.

不以方案名称或斜杠字符开头的相对引用称为相对路径引用。

rel_path = rel_segment [ abs_path ]

rel_路径=rel_段[abs_路径]

      rel_segment   = 1*( unreserved | escaped |
                          ";" | "@" | "&" | "=" | "+" | "$" | "," )
        
      rel_segment   = 1*( unreserved | escaped |
                          ";" | "@" | "&" | "=" | "+" | "$" | "," )
        

Within a relative-path reference, the complete path segments "." and ".." have special meanings: "the current hierarchy level" and "the level above this hierarchy level", respectively. Although this is very similar to their use within Unix-based filesystems to indicate directory levels, these path components are only considered special when resolving a relative-path reference to its absolute form (Section 5.2).

在相对路径引用中,完整路径段“.”和“.”分别具有特殊含义:“当前层次级别”和“此层次级别之上的级别”。尽管这非常类似于在基于Unix的文件系统中使用它们来指示目录级别,但只有在将相对路径引用解析为其绝对形式时,这些路径组件才被认为是特殊的(第5.2节)。

Authors should be aware that a path segment which contains a colon character cannot be used as the first segment of a relative URI path (e.g., "this:that"), because it would be mistaken for a scheme name.

作者应该知道,包含冒号字符的路径段不能用作相对URI路径的第一段(例如,“this:that”),因为它会被误认为是方案名称。

It is therefore necessary to precede such segments with other segments (e.g., "./this:that") in order for them to be referenced as a relative path.

因此,有必要在这些段之前加上其他段(例如“/”this:that“),以便将它们作为相对路径引用。

It is not necessary for all URI within a given scheme to be restricted to the <hier_part> syntax, since the hierarchical properties of that syntax are only necessary when relative URI are used within a particular document. Documents can only make use of relative URI when their base URI fits within the <hier_part> syntax. It is assumed that any document which contains a relative reference will also have a base URI that obeys the syntax. In other words, relative URI cannot be used within a document that has an unsuitable base URI.

没有必要将给定方案中的所有URI限制为<hier_part>语法,因为只有在特定文档中使用相对URI时,才需要该语法的层次属性。文档只能在其基本URI符合<hier\u part>语法时使用相对URI。假设任何包含相对引用的文档也有一个遵循语法的基本URI。换句话说,相对URI不能在具有不合适的基本URI的文档中使用。

Some URI schemes do not allow a hierarchical syntax matching the <hier_part> syntax, and thus cannot use relative references.

一些URI方案不允许与<hier\u part>语法匹配的层次结构语法,因此不能使用相对引用。

5.1. Establishing a Base URI
5.1. 建立基本URI

The term "relative URI" implies that there exists some absolute "base URI" against which the relative reference is applied. Indeed, the base URI is necessary to define the semantics of any relative URI reference; without it, a relative reference is meaningless. In order for relative URI to be usable within a document, the base URI of that document must be known to the parser.

术语“相对URI”意味着存在一些绝对的“基本URI”,相对引用是针对这些“基本URI”应用的。实际上,基本URI是定义任何相对URI引用的语义所必需的;没有它,相对引用就没有意义。为了使相对URI在文档中可用,解析器必须知道该文档的基本URI。

The base URI of a document can be established in one of four ways, listed below in order of precedence. The order of precedence can be thought of in terms of layers, where the innermost defined base URI has the highest precedence. This can be visualized graphically as:

文档的基本URI可以通过以下四种方式之一建立,按优先级顺序列出。优先级顺序可以从层的角度考虑,其中最内层定义的基本URI具有最高的优先级。这可以图形化地显示为:

      .----------------------------------------------------------.
      |  .----------------------------------------------------.  |
      |  |  .----------------------------------------------.  |  |
      |  |  |  .----------------------------------------.  |  |  |
      |  |  |  |  .----------------------------------.  |  |  |  |
      |  |  |  |  |       <relative_reference>       |  |  |  |  |
      |  |  |  |  `----------------------------------'  |  |  |  |
      |  |  |  | (5.1.1) Base URI embedded in the       |  |  |  |
      |  |  |  |         document's content             |  |  |  |
      |  |  |  `----------------------------------------'  |  |  |
      |  |  | (5.1.2) Base URI of the encapsulating entity |  |  |
      |  |  |         (message, document, or none).        |  |  |
      |  |  `----------------------------------------------'  |  |
      |  | (5.1.3) URI used to retrieve the entity            |  |
      |  `----------------------------------------------------'  |
      | (5.1.4) Default Base URI is application-dependent        |
      `----------------------------------------------------------'
        
      .----------------------------------------------------------.
      |  .----------------------------------------------------.  |
      |  |  .----------------------------------------------.  |  |
      |  |  |  .----------------------------------------.  |  |  |
      |  |  |  |  .----------------------------------.  |  |  |  |
      |  |  |  |  |       <relative_reference>       |  |  |  |  |
      |  |  |  |  `----------------------------------'  |  |  |  |
      |  |  |  | (5.1.1) Base URI embedded in the       |  |  |  |
      |  |  |  |         document's content             |  |  |  |
      |  |  |  `----------------------------------------'  |  |  |
      |  |  | (5.1.2) Base URI of the encapsulating entity |  |  |
      |  |  |         (message, document, or none).        |  |  |
      |  |  `----------------------------------------------'  |  |
      |  | (5.1.3) URI used to retrieve the entity            |  |
      |  `----------------------------------------------------'  |
      | (5.1.4) Default Base URI is application-dependent        |
      `----------------------------------------------------------'
        
5.1.1. Base URI within Document Content
5.1.1. 文档内容中的基本URI

Within certain document media types, the base URI of the document can be embedded within the content itself such that it can be readily obtained by a parser. This can be useful for descriptive documents, such as tables of content, which may be transmitted to others through protocols other than their usual retrieval context (e.g., E-Mail or USENET news).

在某些文档媒体类型中,文档的基本URI可以嵌入到内容本身中,以便解析器可以轻松地获取它。这对于描述性文档(如内容表)非常有用,这些文档可以通过协议而不是通常的检索上下文(如电子邮件或USENET新闻)传输给其他人。

It is beyond the scope of this document to specify how, for each media type, the base URI can be embedded. It is assumed that user agents manipulating such media types will be able to obtain the appropriate syntax from that media type's specification. An example of how the base URI can be embedded in the Hypertext Markup Language (HTML) [RFC1866] is provided in Appendix D.

指定如何为每种媒体类型嵌入基本URI超出了本文档的范围。假定操纵此类媒体类型的用户代理将能够从该媒体类型的规范中获得适当的语法。附录D中提供了如何将基本URI嵌入超文本标记语言(HTML)[RFC1866]的示例。

A mechanism for embedding the base URI within MIME container types (e.g., the message and multipart types) is defined by MHTML [RFC2110]. Protocols that do not use the MIME message header syntax, but which do allow some form of tagged metainformation to be included within messages, may define their own syntax for defining the base URI as part of a message.

MHTML[RFC2110]定义了一种在MIME容器类型(例如消息和多部分类型)中嵌入基本URI的机制。不使用MIME消息头语法,但允许在消息中包含某种形式的标记元信息的协议可以定义自己的语法,以将基本URI定义为消息的一部分。

5.1.2. Base URI from the Encapsulating Entity
5.1.2. 来自封装实体的基本URI

If no base URI is embedded, the base URI of a document is defined by the document's retrieval context. For a document that is enclosed within another entity (such as a message or another document), the retrieval context is that entity; thus, the default base URI of the document is the base URI of the entity in which the document is encapsulated.

如果未嵌入基本URI,则文档的基本URI由文档的检索上下文定义。对于包含在另一个实体(如消息或另一个文档)中的文档,检索上下文就是该实体;因此,文档的默认基本URI是封装文档的实体的基本URI。

5.1.3. Base URI from the Retrieval URI
5.1.3. 检索URI中的基URI

If no base URI is embedded and the document is not encapsulated within some other entity (e.g., the top level of a composite entity), then, if a URI was used to retrieve the base document, that URI shall be considered the base URI. Note that if the retrieval was the result of a redirected request, the last URI used (i.e., that which resulted in the actual retrieval of the document) is the base URI.

如果未嵌入基础URI,且文档未封装在其他实体中(例如,复合实体的顶层),则如果使用URI检索基础文档,则该URI应视为基础URI。请注意,如果检索是重定向请求的结果,则最后使用的URI(即导致实际检索文档的URI)是基本URI。

5.1.4. Default Base URI
5.1.4. 默认基URI

If none of the conditions described in Sections 5.1.1--5.1.3 apply, then the base URI is defined by the context of the application. Since this definition is necessarily application-dependent, failing

如果第5.1.1节至第5.1.3节中描述的条件均不适用,则基本URI由应用程序的上下文定义。由于此定义必然依赖于应用程序,因此

to define the base URI using one of the other methods may result in the same content being interpreted differently by different types of application.

使用其他方法之一定义基本URI可能会导致不同类型的应用程序对相同内容进行不同的解释。

It is the responsibility of the distributor(s) of a document containing relative URI to ensure that the base URI for that document can be established. It must be emphasized that relative URI cannot be used reliably in situations where the document's base URI is not well-defined.

包含相对URI的文档的分发者有责任确保可以建立该文档的基本URI。必须强调的是,在文档的基本URI没有很好定义的情况下,相对URI不能可靠地使用。

5.2. Resolving Relative References to Absolute Form
5.2. 将相对引用解析为绝对形式

This section describes an example algorithm for resolving URI references that might be relative to a given base URI.

本节描述用于解析可能与给定基本URI相关的URI引用的示例算法。

The base URI is established according to the rules of Section 5.1 and parsed into the four main components as described in Section 3. Note that only the scheme component is required to be present in the base URI; the other components may be empty or undefined. A component is undefined if its preceding separator does not appear in the URI reference; the path component is never undefined, though it may be empty. The base URI's query component is not used by the resolution algorithm and may be discarded.

基本URI根据第5.1节的规则建立,并按照第3节的描述解析为四个主要组件。注意,基本URI中只需要存在scheme组件;其他组件可能为空或未定义。如果组件前面的分隔符没有出现在URI引用中,则该组件是未定义的;路径组件从来都不是未定义的,尽管它可能是空的。基本URI的查询组件未被解析算法使用,可能会被丢弃。

For each URI reference, the following steps are performed in order:

对于每个URI引用,按顺序执行以下步骤:

1) The URI reference is parsed into the potential four components and fragment identifier, as described in Section 4.3.

1) URI引用被解析为潜在的四个组件和片段标识符,如第4.3节所述。

2) If the path component is empty and the scheme, authority, and query components are undefined, then it is a reference to the current document and we are done. Otherwise, the reference URI's query and fragment components are defined as found (or not found) within the URI reference and not inherited from the base URI.

2) 如果路径组件为空,并且方案、权限和查询组件未定义,那么它就是对当前文档的引用,我们就完成了。否则,引用URI的查询和片段组件被定义为在URI引用中找到(或未找到),而不是从基URI继承。

3) If the scheme component is defined, indicating that the reference starts with a scheme name, then the reference is interpreted as an absolute URI and we are done. Otherwise, the reference URI's scheme is inherited from the base URI's scheme component.

3) 如果定义了scheme组件,指示引用以scheme名称开头,那么引用将被解释为绝对URI,我们就完成了。否则,引用URI的方案将从基URI的方案组件继承。

Due to a loophole in prior specifications [RFC1630], some parsers allow the scheme name to be present in a relative URI if it is the same as the base URI scheme. Unfortunately, this can conflict with the correct parsing of non-hierarchical URI. For backwards compatibility, an implementation may work around such references by removing the scheme if it matches that of the base URI and the scheme is known to always use the <hier_part> syntax. The parser

由于先前规范[RFC1630]中存在漏洞,一些解析器允许方案名称出现在相对URI中,如果它与基本URI方案相同。不幸的是,这可能与非层次URI的正确解析相冲突。为了向后兼容,如果方案与基本URI的方案匹配,并且已知该方案始终使用<hier\u part>语法,则实现可以通过删除该方案来绕过此类引用。解析器

can then continue with the steps below for the remainder of the reference components. Validating parsers should mark such a misformed relative reference as an error.

然后,对于其余的参考组件,可以继续执行以下步骤。验证解析器应该将这种格式错误的相对引用标记为错误。

4) If the authority component is defined, then the reference is a network-path and we skip to step 7. Otherwise, the reference URI's authority is inherited from the base URI's authority component, which will also be undefined if the URI scheme does not use an authority component.

4) 如果定义了authority组件,那么引用是一个网络路径,我们跳到步骤7。否则,引用URI的权限将从基本URI的权限组件继承,如果URI方案不使用权限组件,则该组件也将是未定义的。

5) If the path component begins with a slash character ("/"), then the reference is an absolute-path and we skip to step 7.

5) 如果路径组件以斜杠字符(“/”)开头,那么引用是绝对路径,我们跳到步骤7。

6) If this step is reached, then we are resolving a relative-path reference. The relative path needs to be merged with the base URI's path. Although there are many ways to do this, we will describe a simple method using a separate string buffer.

6) 如果达到此步骤,则我们正在解析相对路径引用。相对路径需要与基本URI的路径合并。尽管有很多方法可以做到这一点,但我们将描述一个使用单独字符串缓冲区的简单方法。

a) All but the last segment of the base URI's path component is copied to the buffer. In other words, any characters after the last (right-most) slash character, if any, are excluded.

a) 除了基本URI的路径组件的最后一段之外,其他所有部分都复制到缓冲区。换句话说,最后一个(最右边的)斜杠字符(如果有)之后的任何字符都被排除在外。

b) The reference's path component is appended to the buffer string.

b) 引用的路径组件追加到缓冲区字符串。

c) All occurrences of "./", where "." is a complete path segment, are removed from the buffer string.

c) 将从缓冲区字符串中删除所有出现的“/”,其中“.”是完整的路径段。

d) If the buffer string ends with "." as a complete path segment, that "." is removed.

d) 如果缓冲区字符串作为完整路径段以“.”结尾,则删除该“.”。

e) All occurrences of "<segment>/../", where <segment> is a complete path segment not equal to "..", are removed from the buffer string. Removal of these path segments is performed iteratively, removing the leftmost matching pattern on each iteration, until no matching pattern remains.

e) 所有出现的“<segment>/../”,其中<segment>是不等于“.”的完整路径段,都将从缓冲区字符串中删除。这些路径段的删除是迭代执行的,在每次迭代中删除最左边的匹配模式,直到没有匹配模式保留。

f) If the buffer string ends with "<segment>/..", where <segment> is a complete path segment not equal to "..", that "<segment>/.." is removed.

f) 如果缓冲字符串以“<segment>/…”结尾,其中<segment>是不等于“.”的完整路径段,则“<segment>/…”将被删除。

g) If the resulting buffer string still begins with one or more complete path segments of "..", then the reference is considered to be in error. Implementations may handle this error by retaining these components in the resolved path (i.e., treating them as part of the final URI), by removing them from the resolved path (i.e., discarding relative levels above the root), or by avoiding traversal of the reference.

g) 如果生成的缓冲区字符串仍然以“.”的一个或多个完整路径段开头,则该引用被认为是错误的。实现可以通过在解析路径中保留这些组件(即,将它们视为最终URI的一部分)、从解析路径中删除它们(即,丢弃根上的相对级别)或避免遍历引用来处理此错误。

h) The remaining buffer string is the reference URI's new path component.

h) 剩余的缓冲区字符串是引用URI的新路径组件。

7) The resulting URI components, including any inherited from the base URI, are recombined to give the absolute form of the URI reference. Using pseudocode, this would be

7) 结果URI组件(包括从基URI继承的任何组件)被重新组合以提供URI引用的绝对形式。使用伪代码,这将是

result = ""

result=“”

if scheme is defined then append scheme to result append ":" to result

如果定义了方案,则将方案追加到结果追加“:”到结果

if authority is defined then append "//" to result append authority to result

如果定义了权限,则将“/”附加到结果将权限附加到结果

append path to result

将路径附加到结果

if query is defined then append "?" to result append query to result

若定义了查询,则将“?”追加到结果将查询追加到结果

if fragment is defined then append "#" to result append fragment to result

如果定义了片段,则将“#”附加到结果将片段附加到结果

return result

返回结果

Note that we must be careful to preserve the distinction between a component that is undefined, meaning that its separator was not present in the reference, and a component that is empty, meaning that the separator was present and was immediately followed by the next component separator or the end of the reference.

请注意,我们必须小心保留未定义的组件(即其分隔符不在引用中)与空组件(即分隔符存在且紧接着下一个组件分隔符或引用结尾)之间的区别。

The above algorithm is intended to provide an example by which the output of implementations can be tested -- implementation of the algorithm itself is not required. For example, some systems may find it more efficient to implement step 6 as a pair of segment stacks being merged, rather than as a series of string pattern replacements.

上述算法旨在提供一个示例,通过该示例可以测试实现的输出——不需要实现算法本身。例如,一些系统可能会发现,将步骤6实现为一对正在合并的段堆栈,而不是一系列字符串模式替换,更有效。

Note: Some WWW client applications will fail to separate the reference's query component from its path component before merging the base and reference paths in step 6 above. This may result in a loss of information if the query component contains the strings "/../" or "/./".

注意:在上面的步骤6中合并基本路径和引用路径之前,一些WWW客户端应用程序将无法将引用的查询组件与其路径组件分离。如果查询组件包含字符串“/../”或“/。/”,这可能会导致信息丢失。

Resolution examples are provided in Appendix C.

附录C中提供了解决方案示例。

6. URI Normalization and Equivalence
6. URI规范化和等价性

In many cases, different URI strings may actually identify the identical resource. For example, the host names used in URL are actually case insensitive, and the URL <http://www.XEROX.com> is equivalent to <http://www.xerox.com>. In general, the rules for equivalence and definition of a normal form, if any, are scheme dependent. When a scheme uses elements of the common syntax, it will also use the common syntax equivalence rules, namely that the scheme and hostname are case insensitive and a URL with an explicit ":port", where the port is the default for the scheme, is equivalent to one where the port is elided.

在许多情况下,不同的URI字符串实际上可能标识相同的资源。例如,URL中使用的主机名实际上不区分大小写,URL<http://www.XEROX.com>相当于<http://www.xerox.com>. 一般来说,标准形式的等价规则和定义(如果有)依赖于方案。当方案使用公共语法的元素时,它还将使用公共语法等价规则,即方案和主机名不区分大小写,并且带有显式“:port”的URL(其中port是方案的默认端口)等效于省略端口的URL。

7. Security Considerations
7. 安全考虑

A URI does not in itself pose a security threat. Users should beware that there is no general guarantee that a URL, which at one time located a given resource, will continue to do so. Nor is there any guarantee that a URL will not locate a different resource at some later point in time, due to the lack of any constraint on how a given authority apportions its namespace. Such a guarantee can only be obtained from the person(s) controlling that namespace and the resource in question. A specific URI scheme may include additional semantics, such as name persistence, if those semantics are required of all naming authorities for that scheme.

URI本身并不构成安全威胁。用户应该注意,不能保证曾经定位给定资源的URL会继续这样做。也不能保证URL不会在以后的某个时间点找到不同的资源,因为给定的权限如何分配其命名空间没有任何约束。这样的保证只能从控制该命名空间和相关资源的人员处获得。如果某个特定URI方案的所有命名机构都需要这些语义,则该方案可能包括其他语义,例如名称持久性。

It is sometimes possible to construct a URL such that an attempt to perform a seemingly harmless, idempotent operation, such as the retrieval of an entity associated with the resource, will in fact cause a possibly damaging remote operation to occur. The unsafe URL is typically constructed by specifying a port number other than that reserved for the network protocol in question. The client unwittingly contacts a site that is in fact running a different protocol. The content of the URL contains instructions that, when interpreted according to this other protocol, cause an unexpected operation. An example has been the use of a gopher URL to cause an unintended or impersonating message to be sent via a SMTP server.

有时可以构造URL,以便尝试执行看似无害的幂等操作(例如检索与资源相关联的实体)实际上会导致发生可能具有破坏性的远程操作。不安全的URL通常是通过指定端口号而不是为相关网络协议保留的端口号来构造的。客户端无意中联系了一个实际运行不同协议的站点。URL的内容包含的指令在根据此其他协议进行解释时会导致意外操作。例如,使用gopher URL通过SMTP服务器发送非预期或模拟邮件。

Caution should be used when using any URL that specifies a port number other than the default for the protocol, especially when it is a number within the reserved space.

当使用指定协议默认端口号以外的端口号的任何URL时,尤其是当它是保留空间内的一个数字时,应谨慎使用。

Care should be taken when a URL contains escaped delimiters for a given protocol (for example, CR and LF characters for telnet protocols) that these are not unescaped before transmission. This might violate the protocol, but avoids the potential for such

当URL包含给定协议的转义定界符(例如,telnet协议的CR和LF字符)时,应注意在传输之前这些转义定界符不是未转义的。这可能会违反协议,但会避免出现此类情况

characters to be used to simulate an extra operation or parameter in that protocol, which might lead to an unexpected and possibly harmful remote operation to be performed.

用于模拟该协议中的额外操作或参数的字符,该操作或参数可能导致执行意外且可能有害的远程操作。

It is clearly unwise to use a URL that contains a password which is intended to be secret. In particular, the use of a password within the 'userinfo' component of a URL is strongly disrecommended except in those rare cases where the 'password' parameter is intended to be public.

使用包含密码的URL显然是不明智的。特别是,强烈建议不要在URL的“userinfo”组件中使用密码,除非“password”参数是公开的。

8. Acknowledgements
8. 致谢

This document was derived from RFC 1738 [RFC1738] and RFC 1808 [RFC1808]; the acknowledgements in those specifications still apply. In addition, contributions by Gisle Aas, Martin Beet, Martin Duerst, Jim Gettys, Martijn Koster, Dave Kristol, Daniel LaLiberte, Foteos Macrides, James Marshall, Ryan Moats, Keith Moore, and Lauren Wood are gratefully acknowledged.

本文件来源于RFC 1738[RFC1738]和RFC 1808[RFC1808];这些规范中的确认仍然适用。此外,感谢Gisle Aas、Martin Beet、Martin Duerst、Jim Gettys、Martijn Koster、Dave Kristol、Daniel LaLiberte、Foteos Macrides、James Marshall、Ryan Moats、Keith Moore和Lauren Wood的贡献。

9. References
9. 工具书类

[RFC2277] Alvestrand, H., "IETF Policy on Character Sets and Languages", BCP 18, RFC 2277, January 1998.

[RFC2277]Alvestrand,H.,“IETF字符集和语言政策”,BCP 18,RFC 2277,1998年1月。

[RFC1630] Berners-Lee, T., "Universal Resource Identifiers in WWW: A Unifying Syntax for the Expression of Names and Addresses of Objects on the Network as used in the World-Wide Web", RFC 1630, June 1994.

[RFC1630]Berners Lee,T.,“万维网中的通用资源标识符:万维网中使用的网络对象名称和地址表达的统一语法”,RFC 1630,1994年6月。

[RFC1738] Berners-Lee, T., Masinter, L., and M. McCahill, Editors, "Uniform Resource Locators (URL)", RFC 1738, December 1994.

[RFC1738]Berners Lee,T.,Masinter,L.,和M.McCahill,编辑,“统一资源定位器(URL)”,RFC 17381994年12月。

[RFC1866] Berners-Lee T., and D. Connolly, "HyperText Markup Language Specification -- 2.0", RFC 1866, November 1995.

[RFC1866]Berners Lee T.和D.Connolly,“超文本标记语言规范——2.0”,RFC 1866,1995年11月。

[RFC1123] Braden, R., Editor, "Requirements for Internet Hosts -- Application and Support", STD 3, RFC 1123, October 1989.

[RFC1123]Braden,R.,编辑,“互联网主机的要求——应用和支持”,STD 3,RFC 1123,1989年10月。

[RFC822] Crocker, D., "Standard for the Format of ARPA Internet Text Messages", STD 11, RFC 822, August 1982.

[RFC822]Crocker,D.,“ARPA互联网文本信息格式标准”,STD 11,RFC 822,1982年8月。

[RFC1808] Fielding, R., "Relative Uniform Resource Locators", RFC 1808, June 1995.

[RFC1808]菲尔丁,R.,“相对统一资源定位器”,RFC18081995年6月。

[RFC2046] Freed, N., and N. Borenstein, "Multipurpose Internet Mail Extensions (MIME) Part Two: Media Types", RFC 2046, November 1996.

[RFC2046]Freed,N.和N.Borenstein,“多用途Internet邮件扩展(MIME)第二部分:媒体类型”,RFC 20461996年11月。

[RFC1736] Kunze, J., "Functional Recommendations for Internet Resource Locators", RFC 1736, February 1995.

[RFC1736]Kunze,J.,“互联网资源定位器的功能建议”,RFC1736,1995年2月。

[RFC2141] Moats, R., "URN Syntax", RFC 2141, May 1997.

[RFC2141]Moats,R.,“瓮语法”,RFC 21411997年5月。

[RFC1034] Mockapetris, P., "Domain Names - Concepts and Facilities", STD 13, RFC 1034, November 1987.

[RFC1034]Mockapetris,P.,“域名-概念和设施”,STD 13,RFC 1034,1987年11月。

[RFC2110] Palme, J., and A. Hopmann, "MIME E-mail Encapsulation of Aggregate Documents, such as HTML (MHTML)", RFC 2110, March 1997.

[RFC2110]Palme,J.和A.Hopmann,“聚合文档的MIME电子邮件封装,如HTML(MHTML)”,RFC 2110,1997年3月。

[RFC1737] Sollins, K., and L. Masinter, "Functional Requirements for Uniform Resource Names", RFC 1737, December 1994.

[RFC1737]Sollins,K.和L.Masinter,“统一资源名称的功能要求”,RFC 1737,1994年12月。

[ASCII] US-ASCII. "Coded Character Set -- 7-bit American Standard Code for Information Interchange", ANSI X3.4-1986.

[ASCII]US-ASCII。“编码字符集——信息交换用7位美国标准代码”,ANSI X3.4-1986。

[UTF-8] Yergeau, F., "UTF-8, a transformation format of ISO 10646", RFC 2279, January 1998.

[UTF-8]Yergeau,F.,“UTF-8,ISO 10646的转换格式”,RFC 2279,1998年1月。

10. Authors' Addresses
10. 作者地址

Tim Berners-Lee World Wide Web Consortium MIT Laboratory for Computer Science, NE43-356 545 Technology Square Cambridge, MA 02139

Tim Berners-Lee万维网联盟麻省理工学院计算机科学实验室,NE43-356 545技术广场剑桥,马萨诸塞州02139

   Fax: +1(617)258-8682
   EMail: timbl@w3.org
        
   Fax: +1(617)258-8682
   EMail: timbl@w3.org
        

Roy T. Fielding Department of Information and Computer Science University of California, Irvine Irvine, CA 92697-3425

罗伊·T·菲尔丁加利福尼亚大学信息与计算机科学系,欧文·欧文,CA92697-3525

   Fax: +1(949)824-1715
   EMail: fielding@ics.uci.edu
        
   Fax: +1(949)824-1715
   EMail: fielding@ics.uci.edu
        

Larry Masinter Xerox PARC 3333 Coyote Hill Road Palo Alto, CA 94034

美国加利福尼亚州帕洛阿尔托市郊狼山路3333号拉里·马辛特施乐公园,邮编94034

   Fax: +1(415)812-4333
   EMail: masinter@parc.xerox.com
        
   Fax: +1(415)812-4333
   EMail: masinter@parc.xerox.com
        

A. Collected BNF for URI

A.为URI收集的BNF

      URI-reference = [ absoluteURI | relativeURI ] [ "#" fragment ]
      absoluteURI   = scheme ":" ( hier_part | opaque_part )
      relativeURI   = ( net_path | abs_path | rel_path ) [ "?" query ]
        
      URI-reference = [ absoluteURI | relativeURI ] [ "#" fragment ]
      absoluteURI   = scheme ":" ( hier_part | opaque_part )
      relativeURI   = ( net_path | abs_path | rel_path ) [ "?" query ]
        
      hier_part     = ( net_path | abs_path ) [ "?" query ]
      opaque_part   = uric_no_slash *uric
        
      hier_part     = ( net_path | abs_path ) [ "?" query ]
      opaque_part   = uric_no_slash *uric
        
      uric_no_slash = unreserved | escaped | ";" | "?" | ":" | "@" |
                      "&" | "=" | "+" | "$" | ","
        
      uric_no_slash = unreserved | escaped | ";" | "?" | ":" | "@" |
                      "&" | "=" | "+" | "$" | ","
        
      net_path      = "//" authority [ abs_path ]
      abs_path      = "/"  path_segments
      rel_path      = rel_segment [ abs_path ]
        
      net_path      = "//" authority [ abs_path ]
      abs_path      = "/"  path_segments
      rel_path      = rel_segment [ abs_path ]
        
      rel_segment   = 1*( unreserved | escaped |
                          ";" | "@" | "&" | "=" | "+" | "$" | "," )
        
      rel_segment   = 1*( unreserved | escaped |
                          ";" | "@" | "&" | "=" | "+" | "$" | "," )
        
      scheme        = alpha *( alpha | digit | "+" | "-" | "." )
        
      scheme        = alpha *( alpha | digit | "+" | "-" | "." )
        

authority = server | reg_name

权限=服务器|注册|名称

      reg_name      = 1*( unreserved | escaped | "$" | "," |
                          ";" | ":" | "@" | "&" | "=" | "+" )
        
      reg_name      = 1*( unreserved | escaped | "$" | "," |
                          ";" | ":" | "@" | "&" | "=" | "+" )
        
      server        = [ [ userinfo "@" ] hostport ]
      userinfo      = *( unreserved | escaped |
                         ";" | ":" | "&" | "=" | "+" | "$" | "," )
        
      server        = [ [ userinfo "@" ] hostport ]
      userinfo      = *( unreserved | escaped |
                         ";" | ":" | "&" | "=" | "+" | "$" | "," )
        
      hostport      = host [ ":" port ]
      host          = hostname | IPv4address
      hostname      = *( domainlabel "." ) toplabel [ "." ]
      domainlabel   = alphanum | alphanum *( alphanum | "-" ) alphanum
      toplabel      = alpha | alpha *( alphanum | "-" ) alphanum
      IPv4address   = 1*digit "." 1*digit "." 1*digit "." 1*digit
      port          = *digit
        
      hostport      = host [ ":" port ]
      host          = hostname | IPv4address
      hostname      = *( domainlabel "." ) toplabel [ "." ]
      domainlabel   = alphanum | alphanum *( alphanum | "-" ) alphanum
      toplabel      = alpha | alpha *( alphanum | "-" ) alphanum
      IPv4address   = 1*digit "." 1*digit "." 1*digit "." 1*digit
      port          = *digit
        
      path          = [ abs_path | opaque_part ]
      path_segments = segment *( "/" segment )
      segment       = *pchar *( ";" param )
      param         = *pchar
      pchar         = unreserved | escaped |
                      ":" | "@" | "&" | "=" | "+" | "$" | ","
        
      path          = [ abs_path | opaque_part ]
      path_segments = segment *( "/" segment )
      segment       = *pchar *( ";" param )
      param         = *pchar
      pchar         = unreserved | escaped |
                      ":" | "@" | "&" | "=" | "+" | "$" | ","
        
      query         = *uric
        
      query         = *uric
        
      fragment      = *uric
        
      fragment      = *uric
        
      uric          = reserved | unreserved | escaped
      reserved      = ";" | "/" | "?" | ":" | "@" | "&" | "=" | "+" |
                      "$" | ","
      unreserved    = alphanum | mark
      mark          = "-" | "_" | "." | "!" | "~" | "*" | "'" |
                      "(" | ")"
        
      uric          = reserved | unreserved | escaped
      reserved      = ";" | "/" | "?" | ":" | "@" | "&" | "=" | "+" |
                      "$" | ","
      unreserved    = alphanum | mark
      mark          = "-" | "_" | "." | "!" | "~" | "*" | "'" |
                      "(" | ")"
        
      escaped       = "%" hex hex
      hex           = digit | "A" | "B" | "C" | "D" | "E" | "F" |
                              "a" | "b" | "c" | "d" | "e" | "f"
        
      escaped       = "%" hex hex
      hex           = digit | "A" | "B" | "C" | "D" | "E" | "F" |
                              "a" | "b" | "c" | "d" | "e" | "f"
        

alphanum = alpha | digit alpha = lowalpha | upalpha

alphanum=alpha |数字alpha=low alpha | upalpha

      lowalpha = "a" | "b" | "c" | "d" | "e" | "f" | "g" | "h" | "i" |
                 "j" | "k" | "l" | "m" | "n" | "o" | "p" | "q" | "r" |
                 "s" | "t" | "u" | "v" | "w" | "x" | "y" | "z"
      upalpha  = "A" | "B" | "C" | "D" | "E" | "F" | "G" | "H" | "I" |
                 "J" | "K" | "L" | "M" | "N" | "O" | "P" | "Q" | "R" |
                 "S" | "T" | "U" | "V" | "W" | "X" | "Y" | "Z"
      digit    = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" |
                 "8" | "9"
        
      lowalpha = "a" | "b" | "c" | "d" | "e" | "f" | "g" | "h" | "i" |
                 "j" | "k" | "l" | "m" | "n" | "o" | "p" | "q" | "r" |
                 "s" | "t" | "u" | "v" | "w" | "x" | "y" | "z"
      upalpha  = "A" | "B" | "C" | "D" | "E" | "F" | "G" | "H" | "I" |
                 "J" | "K" | "L" | "M" | "N" | "O" | "P" | "Q" | "R" |
                 "S" | "T" | "U" | "V" | "W" | "X" | "Y" | "Z"
      digit    = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" |
                 "8" | "9"
        

B. Parsing a URI Reference with a Regular Expression

B.使用正则表达式解析URI引用

As described in Section 4.3, the generic URI syntax is not sufficient to disambiguate the components of some forms of URI. Since the "greedy algorithm" described in that section is identical to the disambiguation method used by POSIX regular expressions, it is natural and commonplace to use a regular expression for parsing the potential four components and fragment identifier of a URI reference.

如第4.3节所述,通用URI语法不足以消除某些形式URI组件的歧义。由于该节中描述的“贪婪算法”与POSIX正则表达式使用的消歧方法相同,因此使用正则表达式解析URI引用的潜在四个组件和片段标识符是自然和常见的。

The following line is the regular expression for breaking-down a URI reference into its components.

下面一行是将URI引用分解为其组件的正则表达式。

      ^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?
       12            3  4          5       6  7        8 9
        
      ^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?
       12            3  4          5       6  7        8 9
        

The numbers in the second line above are only to assist readability; they indicate the reference points for each subexpression (i.e., each paired parenthesis). We refer to the value matched for subexpression <n> as $<n>. For example, matching the above expression to

上面第二行中的数字仅用于帮助可读性;它们表示每个子表达式(即每个成对括号)的参考点。我们将子表达式<n>的匹配值称为$<n>。例如,将上述表达式与

      http://www.ics.uci.edu/pub/ietf/uri/#Related
        
      http://www.ics.uci.edu/pub/ietf/uri/#Related
        

results in the following subexpression matches:

导致以下子表达式匹配:

      $1 = http:
      $2 = http
      $3 = //www.ics.uci.edu
      $4 = www.ics.uci.edu
      $5 = /pub/ietf/uri/
      $6 = <undefined>
      $7 = <undefined>
      $8 = #Related
      $9 = Related
        
      $1 = http:
      $2 = http
      $3 = //www.ics.uci.edu
      $4 = www.ics.uci.edu
      $5 = /pub/ietf/uri/
      $6 = <undefined>
      $7 = <undefined>
      $8 = #Related
      $9 = Related
        

where <undefined> indicates that the component is not present, as is the case for the query component in the above example. Therefore, we can determine the value of the four components and fragment as

其中<undefined>表示组件不存在,如上例中的查询组件。因此,我们可以确定四个组件和片段的值

scheme = $2 authority = $4 path = $5 query = $7 fragment = $9

方案=$2权限=$4路径=$5查询=$7片段=$9

and, going in the opposite direction, we can recreate a URI reference from its components using the algorithm in step 7 of Section 5.2.

相反,我们可以使用第5.2节步骤7中的算法从其组件重新创建URI引用。

C. Examples of Resolving Relative URI References

C.解析相对URI引用的示例

Within an object with a well-defined base URI of

在具有定义良好的基本URI的对象中

      http://a/b/c/d;p?q
        
      http://a/b/c/d;p?q
        

the relative URI would be resolved as follows:

相对URI的解析如下:

C.1. Normal Examples
C.1. 正常示例
      g:h           =  g:h
      g             =  http://a/b/c/g
      ./g           =  http://a/b/c/g
      g/            =  http://a/b/c/g/
      /g            =  http://a/g
      //g           =  http://g
      ?y            =  http://a/b/c/?y
      g?y           =  http://a/b/c/g?y
      #s            =  (current document)#s
      g#s           =  http://a/b/c/g#s
      g?y#s         =  http://a/b/c/g?y#s
      ;x            =  http://a/b/c/;x
      g;x           =  http://a/b/c/g;x
      g;x?y#s       =  http://a/b/c/g;x?y#s
      .             =  http://a/b/c/
      ./            =  http://a/b/c/
      ..            =  http://a/b/
      ../           =  http://a/b/
      ../g          =  http://a/b/g
      ../..         =  http://a/
      ../../        =  http://a/
      ../../g       =  http://a/g
        
      g:h           =  g:h
      g             =  http://a/b/c/g
      ./g           =  http://a/b/c/g
      g/            =  http://a/b/c/g/
      /g            =  http://a/g
      //g           =  http://g
      ?y            =  http://a/b/c/?y
      g?y           =  http://a/b/c/g?y
      #s            =  (current document)#s
      g#s           =  http://a/b/c/g#s
      g?y#s         =  http://a/b/c/g?y#s
      ;x            =  http://a/b/c/;x
      g;x           =  http://a/b/c/g;x
      g;x?y#s       =  http://a/b/c/g;x?y#s
      .             =  http://a/b/c/
      ./            =  http://a/b/c/
      ..            =  http://a/b/
      ../           =  http://a/b/
      ../g          =  http://a/b/g
      ../..         =  http://a/
      ../../        =  http://a/
      ../../g       =  http://a/g
        
C.2. Abnormal Examples
C.2. 异常例子

Although the following abnormal examples are unlikely to occur in normal practice, all URI parsers should be capable of resolving them consistently. Each example uses the same base as above.

尽管在正常实践中不太可能出现以下异常示例,但所有URI解析器都应该能够一致地解析它们。每个示例使用与上述相同的基础。

An empty reference refers to the start of the current document.

空引用是指当前文档的开头。

      <>            =  (current document)
        
      <>            =  (current document)
        

Parsers must be careful in handling the case where there are more relative path ".." segments than there are hierarchical levels in the base URI's path. Note that the ".." syntax cannot be used to change the authority component of a URI.

在处理相对路径“.”段多于基本URI路径中的层次结构的情况时,解析器必须小心。请注意,“.”语法不能用于更改URI的权限组件。

      ../../../g    =  http://a/../g
      ../../../../g =  http://a/../../g
        
      ../../../g    =  http://a/../g
      ../../../../g =  http://a/../../g
        

In practice, some implementations strip leading relative symbolic elements (".", "..") after applying a relative URI calculation, based on the theory that compensating for obvious author errors is better than allowing the request to fail. Thus, the above two references will be interpreted as "http://a/g" by some implementations.

在实践中,一些实现在应用相对URI计算后剥离了前导的相对符号元素(“.”、“.”),其原理是补偿明显的作者错误比允许请求失败要好。因此,上述两个参考将被解释为“http://a/g“通过一些实现。

Similarly, parsers must avoid treating "." and ".." as special when they are not complete components of a relative path.

类似地,当“.”和“.”不是相对路径的完整组件时,解析器必须避免将它们视为特殊组件。

      /./g          =  http://a/./g
      /../g         =  http://a/../g
      g.            =  http://a/b/c/g.
      .g            =  http://a/b/c/.g
      g..           =  http://a/b/c/g..
      ..g           =  http://a/b/c/..g
        
      /./g          =  http://a/./g
      /../g         =  http://a/../g
      g.            =  http://a/b/c/g.
      .g            =  http://a/b/c/.g
      g..           =  http://a/b/c/g..
      ..g           =  http://a/b/c/..g
        

Less likely are cases where the relative URI uses unnecessary or nonsensical forms of the "." and ".." complete path segments.

相对URI使用不必要或无意义的“.”和“.”完整路径段的情况不太可能出现。

      ./../g        =  http://a/b/g
      ./g/.         =  http://a/b/c/g/
      g/./h         =  http://a/b/c/g/h
      g/../h        =  http://a/b/c/h
      g;x=1/./y     =  http://a/b/c/g;x=1/y
      g;x=1/../y    =  http://a/b/c/y
        
      ./../g        =  http://a/b/g
      ./g/.         =  http://a/b/c/g/
      g/./h         =  http://a/b/c/g/h
      g/../h        =  http://a/b/c/h
      g;x=1/./y     =  http://a/b/c/g;x=1/y
      g;x=1/../y    =  http://a/b/c/y
        

All client applications remove the query component from the base URI before resolving relative URI. However, some applications fail to separate the reference's query and/or fragment components from a relative path before merging it with the base path. This error is rarely noticed, since typical usage of a fragment never includes the hierarchy ("/") character, and the query component is not normally used within relative references.

在解析相对URI之前,所有客户端应用程序都会从基本URI中删除查询组件。但是,有些应用程序在将引用的查询和/或片段组件与基本路径合并之前,无法将其与相对路径分离。很少注意到这个错误,因为片段的典型用法从不包括层次结构(“/”)字符,并且查询组件通常不在相对引用中使用。

      g?y/./x       =  http://a/b/c/g?y/./x
      g?y/../x      =  http://a/b/c/g?y/../x
      g#s/./x       =  http://a/b/c/g#s/./x
      g#s/../x      =  http://a/b/c/g#s/../x
        
      g?y/./x       =  http://a/b/c/g?y/./x
      g?y/../x      =  http://a/b/c/g?y/../x
      g#s/./x       =  http://a/b/c/g#s/./x
      g#s/../x      =  http://a/b/c/g#s/../x
        

Some parsers allow the scheme name to be present in a relative URI if it is the same as the base URI scheme. This is considered to be a loophole in prior specifications of partial URI [RFC1630]. Its use should be avoided.

如果方案名称与基本URI方案相同,则某些解析器允许该方案名称出现在相对URI中。这被认为是先前部分URI规范[RFC1630]中的漏洞。应该避免使用它。

      http:g        =  http:g           ; for validating parsers
                    |  http://a/b/c/g   ; for backwards compatibility
        
      http:g        =  http:g           ; for validating parsers
                    |  http://a/b/c/g   ; for backwards compatibility
        

D. Embedding the Base URI in HTML documents

D.在HTML文档中嵌入基本URI

It is useful to consider an example of how the base URI of a document can be embedded within the document's content. In this appendix, we describe how documents written in the Hypertext Markup Language (HTML) [RFC1866] can include an embedded base URI. This appendix does not form a part of the URI specification and should not be considered as anything more than a descriptive example.

考虑文档的基URI可以嵌入文档内容中的例子是有用的。在本附录中,我们描述了用超文本标记语言(HTML)[RFC1866]编写的文档如何包含嵌入式基本URI。本附录不构成URI规范的一部分,仅作为一个描述性示例。

HTML defines a special element "BASE" which, when present in the "HEAD" portion of a document, signals that the parser should use the BASE element's "HREF" attribute as the base URI for resolving any relative URI. The "HREF" attribute must be an absolute URI. Note that, in HTML, element and attribute names are case-insensitive. For example:

HTML定义了一个特殊的元素“BASE”,当它出现在文档的“HEAD”部分时,表示解析器应该使用BASE元素的“HREF”属性作为解析任何相对URI的基本URI。“HREF”属性必须是绝对URI。注意,在HTML中,元素和属性名称不区分大小写。例如:

      <!doctype html public "-//IETF//DTD HTML//EN">
      <HTML><HEAD>
      <TITLE>An example HTML document</TITLE>
      <BASE href="http://www.ics.uci.edu/Test/a/b/c">
      </HEAD><BODY>
      ... <A href="../x">a hypertext anchor</A> ...
      </BODY></HTML>
        
      <!doctype html public "-//IETF//DTD HTML//EN">
      <HTML><HEAD>
      <TITLE>An example HTML document</TITLE>
      <BASE href="http://www.ics.uci.edu/Test/a/b/c">
      </HEAD><BODY>
      ... <A href="../x">a hypertext anchor</A> ...
      </BODY></HTML>
        

A parser reading the example document should interpret the given relative URI "../x" as representing the absolute URI

读取示例文档的解析器应该将给定的相对URI“./x”解释为表示绝对URI

      <http://www.ics.uci.edu/Test/a/x>
        
      <http://www.ics.uci.edu/Test/a/x>
        

regardless of the context in which the example document was obtained.

不管获取示例文档的上下文是什么。

E. Recommendations for Delimiting URI in Context

E.在上下文中界定URI的建议

URI are often transmitted through formats that do not provide a clear context for their interpretation. For example, there are many occasions when URI are included in plain text; examples include text sent in electronic mail, USENET news messages, and, most importantly, printed on paper. In such cases, it is important to be able to delimit the URI from the rest of the text, and in particular from punctuation marks that might be mistaken for part of the URI.

URI通常通过不为其解释提供清晰上下文的格式传输。例如,在很多情况下,URI包含在纯文本中;示例包括电子邮件发送的文本、USENET新闻消息,最重要的是,打印在纸上。在这种情况下,重要的是能够将URI与文本的其余部分分隔开来,特别是与可能被误认为URI一部分的标点符号分隔开来。

   In practice, URI are delimited in a variety of ways, but usually
   within double-quotes "http://test.com/", angle brackets
   <http://test.com/>, or just using whitespace
        
   In practice, URI are delimited in a variety of ways, but usually
   within double-quotes "http://test.com/", angle brackets
   <http://test.com/>, or just using whitespace
        
                             http://test.com/
        
                             http://test.com/
        

These wrappers do not form part of the URI.

这些包装器不构成URI的一部分。

In the case where a fragment identifier is associated with a URI reference, the fragment would be placed within the brackets as well (separated from the URI with a "#" character).

在片段标识符与URI引用关联的情况下,片段也将放在括号内(用“#”字符与URI分隔)。

In some cases, extra whitespace (spaces, linebreaks, tabs, etc.) may need to be added to break long URI across lines. The whitespace should be ignored when extracting the URI.

在某些情况下,可能需要添加额外的空白(空格、换行符、制表符等),以便跨行断开长URI。提取URI时应忽略空白。

No whitespace should be introduced after a hyphen ("-") character. Because some typesetters and printers may (erroneously) introduce a hyphen at the end of line when breaking a line, the interpreter of a URI containing a line break immediately after a hyphen should ignore all unescaped whitespace around the line break, and should be aware that the hyphen may or may not actually be part of the URI.

在连字符(“-”)后不应引入空格。由于某些排字机和打印机在断行时可能(错误地)在行尾引入连字符,因此在一个连字符之后立即包含一个断行符的URI的解释器应该忽略断行符周围所有未转义的空格,并且应该知道连字符可能是或可能不是URI的一部分。

Using <> angle brackets around each URI is especially recommended as a delimiting style for URI that contain whitespace.

特别推荐在每个URI周围使用<>尖括号作为包含空格的URI的分隔样式。

The prefix "URL:" (with or without a trailing space) was recommended as a way to used to help distinguish a URL from other bracketed designators, although this is not common in practice.

建议使用前缀“URL:”(带或不带尾随空格)来帮助区分URL与其他括号内的指示符,尽管这在实践中并不常见。

For robustness, software that accepts user-typed URI should attempt to recognize and strip both delimiters and embedded whitespace.

为了健壮性,接受用户类型URI的软件应该尝试识别并去除分隔符和嵌入的空白。

For example, the text:

例如,文本:

Yes, Jim, I found it under "http://www.w3.org/Addressing/", but you can probably pick it up from <ftp://ds.internic. net/rfc/>. Note the warning in <http://www.ics.uci.edu/pub/ ietf/uri/historical.html#WARNING>.

是的,吉姆,我在下面找到的“http://www.w3.org/Addressing/“,但您可能可以从<ftp://ds.internic. net/rfc/>。请注意中的警告<http://www.ics.uci.edu/pub/ ietf/uri/historical.html#WARNING>。

contains the URI references

包含URI引用

      http://www.w3.org/Addressing/
      ftp://ds.internic.net/rfc/
      http://www.ics.uci.edu/pub/ietf/uri/historical.html#WARNING
        
      http://www.w3.org/Addressing/
      ftp://ds.internic.net/rfc/
      http://www.ics.uci.edu/pub/ietf/uri/historical.html#WARNING
        

F. Abbreviated URLs

F.缩写URL

The URL syntax was designed for unambiguous reference to network resources and extensibility via the URL scheme. However, as URL identification and usage have become commonplace, traditional media (television, radio, newspapers, billboards, etc.) have increasingly used abbreviated URL references. That is, a reference consisting of only the authority and path portions of the identified resource, such as

URL语法旨在通过URL方案明确引用网络资源和可扩展性。然而,随着URL识别和使用变得司空见惯,传统媒体(电视、广播、报纸、广告牌等)越来越多地使用缩写URL引用。也就是说,仅由所标识资源的权限和路径部分组成的引用,例如

www.w3.org/Addressing/

www.w3.org/Addressing/

or simply the DNS hostname on its own. Such references are primarily intended for human interpretation rather than machine, with the assumption that context-based heuristics are sufficient to complete the URL (e.g., most hostnames beginning with "www" are likely to have a URL prefix of "http://"). Although there is no standard set of heuristics for disambiguating abbreviated URL references, many client implementations allow them to be entered by the user and heuristically resolved. It should be noted that such heuristics may change over time, particularly when new URL schemes are introduced.

或者仅仅是DNS主机名本身。此类引用主要用于人工解释而非机器解释,前提是基于上下文的试探法足以完成URL(例如,大多数以“www”开头的主机名可能具有URL前缀“http://”)。尽管没有一套标准的启发式方法来消除缩写URL引用的歧义,但许多客户端实现允许用户输入它们并以启发式方式解决。应该注意的是,这种启发式可能会随着时间的推移而改变,特别是在引入新的URL方案时。

Since an abbreviated URL has the same syntax as a relative URL path, abbreviated URL references cannot be used in contexts where relative URLs are expected. This limits the use of abbreviated URLs to places where there is no defined base URL, such as dialog boxes and off-line advertisements.

由于缩写URL与相对URL路径具有相同的语法,因此不能在需要相对URL的上下文中使用缩写URL引用。这将缩写URL的使用限制在没有定义基本URL的位置,例如对话框和离线广告。

G. Summary of Non-editorial Changes

G.非编辑性更改摘要

G.1. Additions
G.1. 添加物

Section 4 (URI References) was added to stem the confusion regarding "what is a URI" and how to describe fragment identifiers given that they are not part of the URI, but are part of the URI syntax and parsing concerns. In addition, it provides a reference definition for use by other IETF specifications (HTML, HTTP, etc.) that have previously attempted to redefine the URI syntax in order to account for the presence of fragment identifiers in URI references.

添加第4节(URI引用)是为了避免关于“什么是URI”以及如何描述片段标识符的混淆,因为它们不是URI的一部分,而是URI语法和解析关注点的一部分。此外,它还提供了一个参考定义,供其他IETF规范(HTML、HTTP等)使用,这些规范以前曾试图重新定义URI语法,以说明URI参考中存在的片段标识符。

Section 2.4 was rewritten to clarify a number of misinterpretations and to leave room for fully internationalized URI.

第2.4节被改写,以澄清一些误解,并为完全国际化的URI留出空间。

Appendix F on abbreviated URLs was added to describe the shortened references often seen on television and magazine advertisements and explain why they are not used in other contexts.

添加了关于缩写URL的附录F,以描述电视和杂志广告中经常出现的缩写引用,并解释为什么它们不在其他上下文中使用。

G.2. Modifications from both RFC 1738 and RFC 1808
G.2. RFC 1738和RFC 1808的修改

Changed to URI syntax instead of just URL.

更改为URI语法,而不仅仅是URL。

Confusion regarding the terms "character encoding", the URI "character set", and the escaping of characters with %<hex><hex> equivalents has (hopefully) been reduced. Many of the BNF rule names regarding the character sets have been changed to more accurately describe their purpose and to encompass all "characters" rather than just US-ASCII octets. Unless otherwise noted here, these modifications do not affect the URI syntax.

关于术语“字符编码”、URI“字符集”以及使用%<hex><hex>等价物转义字符的混淆(希望)已经减少。许多关于字符集的BNF规则名称已经更改,以更准确地描述其用途,并包含所有“字符”,而不仅仅是US-ASCII八位字节。除非此处另有说明,否则这些修改不会影响URI语法。

Both RFC 1738 and RFC 1808 refer to the "reserved" set of characters as if URI-interpreting software were limited to a single set of characters with a reserved purpose (i.e., as meaning something other than the data to which the characters correspond), and that this set was fixed by the URI scheme. However, this has not been true in practice; any character that is interpreted differently when it is escaped is, in effect, reserved. Furthermore, the interpreting engine on a HTTP server is often dependent on the resource, not just the URI scheme. The description of reserved characters has been changed accordingly.

RFC 1738和RFC 1808都引用“保留”字符集,就好像URI解释软件被限制为具有保留目的的单个字符集(即,表示字符对应的数据以外的内容),并且该集由URI方案固定。但实际情况并非如此,;任何在转义时被不同解释的字符实际上都是保留的。此外,HTTP服务器上的解释引擎通常依赖于资源,而不仅仅是URI方案。保留字符的描述已相应更改。

The plus "+", dollar "$", and comma "," characters have been added to those in the "reserved" set, since they are treated as reserved within the query component.

加“+”、美元“$”和逗号“,”字符已添加到“保留”集中的字符中,因为它们在查询组件中被视为保留字符。

The tilde "~" character was added to those in the "unreserved" set, since it is extensively used on the Internet in spite of the difficulty to transcribe it with some keyboards.

波浪号“~”字符被添加到“无保留”字符集中,因为它在互联网上被广泛使用,尽管用一些键盘很难转录。

The syntax for URI scheme has been changed to require that all schemes begin with an alpha character.

URI方案的语法已更改为要求所有方案以字母字符开头。

The "user:password" form in the previous BNF was changed to a "userinfo" token, and the possibility that it might be "user:password" made scheme specific. In particular, the use of passwords in the clear is not even suggested by the syntax.

先前BNF中的“user:password”表单被更改为“userinfo”令牌,并且可能是“user:password”使得方案特定。特别是,语法甚至不建议在clear中使用密码。

The question-mark "?" character was removed from the set of allowed characters for the userinfo in the authority component, since testing showed that many applications treat it as reserved for separating the query component from the rest of the URI.

由于测试表明许多应用程序将其视为用于将查询组件与URI的其余部分分离的保留字符,因此已从授权组件中userinfo的允许字符集中删除了问号“?”字符。

The semicolon ";" character was added to those stated as being reserved within the authority component, since several new schemes are using it as a separator within userinfo to indicate the type of user authentication.

分号“;”字符被添加到授权组件中声明为保留的字符中,因为有几个新方案将其用作userinfo中的分隔符,以指示用户身份验证的类型。

RFC 1738 specified that the path was separated from the authority portion of a URI by a slash. RFC 1808 followed suit, but with a fudge of carrying around the separator as a "prefix" in order to describe the parsing algorithm. RFC 1630 never had this problem, since it considered the slash to be part of the path. In writing this specification, it was found to be impossible to accurately describe and retain the difference between the two URI <foo:/bar> and <foo:bar> without either considering the slash to be part of the path (as corresponds to actual practice) or creating a separate component just to hold that slash. We chose the former.

RFC1738指定路径与URI的授权部分用斜杠分隔。RFC1808紧随其后,但为了描述解析算法,使用了将分隔符作为“前缀”的软文。RFC1630从未遇到过这个问题,因为它认为斜杠是路径的一部分。在编写本规范时,我们发现,如果不将斜杠视为路径的一部分(与实际操作相对应),或者不创建单独的组件来保持斜杠,就不可能准确地描述和保留两个URI<foo:/bar>和<foo:bar>之间的差异。我们选择了前者。

G.3. Modifications from RFC 1738
G.3. RFC 1738的修改

The definition of specific URL schemes and their scheme-specific syntax and semantics has been moved to separate documents.

特定URL方案的定义及其特定于方案的语法和语义已移动到单独的文档中。

The URL host was defined as a fully-qualified domain name. However, many URLs are used without fully-qualified domain names (in contexts for which the full qualification is not necessary), without any host (as in some file URLs), or with a host of "localhost".

URL主机被定义为完全限定的域名。但是,许多URL使用时没有完全限定的域名(在不需要完全限定的上下文中)、没有任何主机(如在某些文件URL中)或主机为“localhost”。

The URL port is now *digit instead of 1*digit, since systems are expected to handle the case where the ":" separator between host and port is supplied without a port.

URL端口现在是*位而不是1*位,因为系统需要处理主机和端口之间的“:”分隔符不带端口的情况。

The recommendations for delimiting URI in context (Appendix E) have been adjusted to reflect current practice.

已对上下文中划定URI的建议(附录E)进行了调整,以反映当前的做法。

G.4. Modifications from RFC 1808
G.4. RFC1808的修改

RFC 1808 (Section 4) defined an empty URL reference (a reference containing nothing aside from the fragment identifier) as being a reference to the base URL. Unfortunately, that definition could be interpreted, upon selection of such a reference, as a new retrieval action on that resource. Since the normal intent of such references is for the user agent to change its view of the current document to the beginning of the specified fragment within that document, not to make an additional request of the resource, a description of how to correctly interpret an empty reference has been added in Section 4.

RFC1808(第4节)将空URL引用(除了片段标识符之外不包含任何内容的引用)定义为对基本URL的引用。不幸的是,在选择这样一个引用时,该定义可能被解释为对该资源的新检索操作。由于此类引用的正常目的是让用户代理将其当前文档的视图更改为该文档中指定片段的开头,而不是对资源发出额外请求,因此在第4节中添加了关于如何正确解释空引用的说明。

The description of the mythical Base header field has been replaced with a reference to the Content-Location header field defined by MHTML [RFC2110].

mythical Base header字段的描述已替换为对MHTML[RFC2110]定义的Content Location header字段的引用。

RFC 1808 described various schemes as either having or not having the properties of the generic URI syntax. However, the only requirement is that the particular document containing the relative references have a base URI that abides by the generic URI syntax, regardless of the URI scheme, so the associated description has been updated to reflect that.

RFC1808将各种方案描述为具有或不具有通用URI语法的属性。但是,唯一的要求是,包含相对引用的特定文档有一个遵循通用URI语法的基本URI,而不管URI方案如何,因此相关描述已更新以反映这一点。

The BNF term <net_loc> has been replaced with <authority>, since the latter more accurately describes its use and purpose. Likewise, the authority is no longer restricted to the IP server syntax.

BNF术语<net_loc>已替换为<authority>,因为后者更准确地描述了其用途和目的。同样,授权不再局限于IP服务器语法。

Extensive testing of current client applications demonstrated that the majority of deployed systems do not use the ";" character to indicate trailing parameter information, and that the presence of a semicolon in a path segment does not affect the relative parsing of that segment. Therefore, parameters have been removed as a separate component and may now appear in any path segment. Their influence has been removed from the algorithm for resolving a relative URI reference. The resolution examples in Appendix C have been modified to reflect this change.

对当前客户端应用程序的广泛测试表明,大多数部署的系统不使用“;”字符表示尾部参数信息,并且路径段中分号的存在不会影响该段的相对解析。因此,参数已作为单独的组件删除,现在可能出现在任何路径段中。它们的影响已从解析相对URI引用的算法中移除。已修改附录C中的解决方案示例,以反映这一变化。

Implementations are now allowed to work around misformed relative references that are prefixed by the same scheme as the base URI, but only for schemes known to use the <hier_part> syntax.

现在允许实现处理格式错误的相对引用,这些引用的前缀与基本URI相同,但仅适用于已知使用<hier\u part>语法的方案。

H. Full Copyright Statement

H.完整的版权声明

Copyright (C) The Internet Society (1998). All Rights Reserved.

版权所有(C)互联网协会(1998年)。版权所有。

This document and translations of it may be copied and furnished to others, and derivative works that comment on or otherwise explain it or assist in its implementation may be prepared, copied, published and distributed, in whole or in part, without restriction of any kind, provided that the above copyright notice and this paragraph are included on all such copies and derivative works. However, this document itself may not be modified in any way, such as by removing the copyright notice or references to the Internet Society or other Internet organizations, except as needed for the purpose of developing Internet standards in which case the procedures for copyrights defined in the Internet Standards process must be followed, or as required to translate it into languages other than English.

本文件及其译本可复制并提供给他人,对其进行评论或解释或协助其实施的衍生作品可全部或部分编制、复制、出版和分发,不受任何限制,前提是上述版权声明和本段包含在所有此类副本和衍生作品中。但是,不得以任何方式修改本文件本身,例如删除版权通知或对互联网协会或其他互联网组织的引用,除非出于制定互联网标准的需要,在这种情况下,必须遵循互联网标准过程中定义的版权程序,或根据需要将其翻译成英语以外的其他语言。

The limited permissions granted above are perpetual and will not be revoked by the Internet Society or its successors or assigns.

上述授予的有限许可是永久性的,互联网协会或其继承人或受让人不会撤销。

This document and the information contained herein is provided on an "AS IS" basis and THE INTERNET SOCIETY AND THE INTERNET ENGINEERING TASK FORCE DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.

本文件和其中包含的信息是按“原样”提供的,互联网协会和互联网工程任务组否认所有明示或暗示的保证,包括但不限于任何保证,即使用本文中的信息不会侵犯任何权利,或对适销性或特定用途适用性的任何默示保证。