Internet Engineering Task Force (IETF) M. Nottingham Request for Comments: 8288 October 2017 Obsoletes: 5988 Category: Standards Track ISSN: 2070-1721
Internet Engineering Task Force (IETF) M. Nottingham Request for Comments: 8288 October 2017 Obsoletes: 5988 Category: Standards Track ISSN: 2070-1721
Web Linking
网页链接
Abstract
摘要
This specification defines a model for the relationships between resources on the Web ("links") and the type of those relationships ("link relation types").
本规范定义了Web资源(“链接”)与这些关系类型(“链接关系类型”)之间关系的模型。
It also defines the serialisation of such links in HTTP headers with the Link header field.
它还使用linkheader字段定义了HTTP头中此类链接的序列化。
Status of This Memo
关于下段备忘
This is an Internet Standards Track document.
这是一份互联网标准跟踪文件。
This document is a product of the Internet Engineering Task Force (IETF). It represents the consensus of the IETF community. It has received public review and has been approved for publication by the Internet Engineering Steering Group (IESG). Further information on Internet Standards is available in Section 2 of RFC 7841.
本文件是互联网工程任务组(IETF)的产品。它代表了IETF社区的共识。它已经接受了公众审查,并已被互联网工程指导小组(IESG)批准出版。有关互联网标准的更多信息,请参见RFC 7841第2节。
Information about the current status of this document, any errata, and how to provide feedback on it may be obtained at https://www.rfc-editor.org/info/rfc8288.
有关本文件当前状态、任何勘误表以及如何提供反馈的信息,请访问https://www.rfc-editor.org/info/rfc8288.
Copyright Notice
版权公告
Copyright (c) 2017 IETF Trust and the persons identified as the document authors. All rights reserved.
版权所有(c)2017 IETF信托基金和确定为文件作者的人员。版权所有。
This document is subject to BCP 78 and the IETF Trust's Legal Provisions Relating to IETF Documents (https://trustee.ietf.org/license-info) in effect on the date of publication of this document. Please review these documents carefully, as they describe your rights and restrictions with respect to this document. Code Components extracted from this document must include Simplified BSD License text as described in Section 4.e of the Trust Legal Provisions and are provided without warranty as described in the Simplified BSD License.
本文件受BCP 78和IETF信托有关IETF文件的法律规定的约束(https://trustee.ietf.org/license-info)自本文件出版之日起生效。请仔细阅读这些文件,因为它们描述了您对本文件的权利和限制。从本文件中提取的代码组件必须包括信托法律条款第4.e节中所述的简化BSD许可证文本,并提供简化BSD许可证中所述的无担保。
This document may contain material from IETF Documents or IETF Contributions published or made publicly available before November 10, 2008. The person(s) controlling the copyright in some of this material may not have granted the IETF Trust the right to allow modifications of such material outside the IETF Standards Process. Without obtaining an adequate license from the person(s) controlling the copyright in such materials, this document may not be modified outside the IETF Standards Process, and derivative works of it may not be created outside the IETF Standards Process, except to format it for publication as an RFC or to translate it into languages other than English.
本文件可能包含2008年11月10日之前发布或公开的IETF文件或IETF贡献中的材料。控制某些材料版权的人员可能未授予IETF信托允许在IETF标准流程之外修改此类材料的权利。在未从控制此类材料版权的人员处获得充分许可的情况下,不得在IETF标准流程之外修改本文件,也不得在IETF标准流程之外创建其衍生作品,除了将其格式化以RFC形式发布或将其翻译成英语以外的其他语言。
Table of Contents
目录
1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 4 1.1. Notational Conventions . . . . . . . . . . . . . . . . . 4 1.2. Conformance and Error Handling . . . . . . . . . . . . . 4 2. Links . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 2.1. Link Relation Types . . . . . . . . . . . . . . . . . . . 6 2.1.1. Registered Relation Types . . . . . . . . . . . . . . 6 2.1.2. Extension Relation Types . . . . . . . . . . . . . . 8 2.2. Target Attributes . . . . . . . . . . . . . . . . . . . . 9 3. Link Serialisation in HTTP Headers . . . . . . . . . . . . . 9 3.1. Link Target . . . . . . . . . . . . . . . . . . . . . . . 10 3.2. Link Context . . . . . . . . . . . . . . . . . . . . . . 10 3.3. Relation Type . . . . . . . . . . . . . . . . . . . . . . 11 3.4. Target Attributes . . . . . . . . . . . . . . . . . . . . 11 3.4.1. Serialisation-Defined Attributes . . . . . . . . . . 11 3.4.2. Extension Attributes . . . . . . . . . . . . . . . . 13 3.5. Link Header Field Examples . . . . . . . . . . . . . . . 13 4. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 14 4.1. Link HTTP Header Field Registration . . . . . . . . . . . 14 4.2. Link Relation Type Registry . . . . . . . . . . . . . . . 14 4.3. Link Relation Application Data Registry . . . . . . . . . 15 5. Security Considerations . . . . . . . . . . . . . . . . . . . 15 6. Internationalisation Considerations . . . . . . . . . . . . . 16 7. References . . . . . . . . . . . . . . . . . . . . . . . . . 16 7.1. Normative References . . . . . . . . . . . . . . . . . . 16 7.2. Informative References . . . . . . . . . . . . . . . . . 17 Appendix A. Notes on Other Link Serialisations . . . . . . . . . 19 A.1. Link Serialisation in HTML . . . . . . . . . . . . . . . 19 A.2. Link Serialisation in Atom . . . . . . . . . . . . . . . 19 Appendix B. Algorithms for Parsing Link Header Fields . . . . . 20 B.1. Parsing a Header Set for Links . . . . . . . . . . . . . 20 B.2. Parsing a Link Field Value . . . . . . . . . . . . . . . 21 B.3. Parsing Parameters . . . . . . . . . . . . . . . . . . . 22 B.4. Parsing a Quoted String . . . . . . . . . . . . . . . . . 23 Appendix C. Changes from RFC 5988 . . . . . . . . . . . . . . . 24 Author's Address . . . . . . . . . . . . . . . . . . . . . . . . 24
1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 4 1.1. Notational Conventions . . . . . . . . . . . . . . . . . 4 1.2. Conformance and Error Handling . . . . . . . . . . . . . 4 2. Links . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 2.1. Link Relation Types . . . . . . . . . . . . . . . . . . . 6 2.1.1. Registered Relation Types . . . . . . . . . . . . . . 6 2.1.2. Extension Relation Types . . . . . . . . . . . . . . 8 2.2. Target Attributes . . . . . . . . . . . . . . . . . . . . 9 3. Link Serialisation in HTTP Headers . . . . . . . . . . . . . 9 3.1. Link Target . . . . . . . . . . . . . . . . . . . . . . . 10 3.2. Link Context . . . . . . . . . . . . . . . . . . . . . . 10 3.3. Relation Type . . . . . . . . . . . . . . . . . . . . . . 11 3.4. Target Attributes . . . . . . . . . . . . . . . . . . . . 11 3.4.1. Serialisation-Defined Attributes . . . . . . . . . . 11 3.4.2. Extension Attributes . . . . . . . . . . . . . . . . 13 3.5. Link Header Field Examples . . . . . . . . . . . . . . . 13 4. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 14 4.1. Link HTTP Header Field Registration . . . . . . . . . . . 14 4.2. Link Relation Type Registry . . . . . . . . . . . . . . . 14 4.3. Link Relation Application Data Registry . . . . . . . . . 15 5. Security Considerations . . . . . . . . . . . . . . . . . . . 15 6. Internationalisation Considerations . . . . . . . . . . . . . 16 7. References . . . . . . . . . . . . . . . . . . . . . . . . . 16 7.1. Normative References . . . . . . . . . . . . . . . . . . 16 7.2. Informative References . . . . . . . . . . . . . . . . . 17 Appendix A. Notes on Other Link Serialisations . . . . . . . . . 19 A.1. Link Serialisation in HTML . . . . . . . . . . . . . . . 19 A.2. Link Serialisation in Atom . . . . . . . . . . . . . . . 19 Appendix B. Algorithms for Parsing Link Header Fields . . . . . 20 B.1. Parsing a Header Set for Links . . . . . . . . . . . . . 20 B.2. Parsing a Link Field Value . . . . . . . . . . . . . . . 21 B.3. Parsing Parameters . . . . . . . . . . . . . . . . . . . 22 B.4. Parsing a Quoted String . . . . . . . . . . . . . . . . . 23 Appendix C. Changes from RFC 5988 . . . . . . . . . . . . . . . 24 Author's Address . . . . . . . . . . . . . . . . . . . . . . . . 24
This specification defines a model for the relationships between resources on the Web ("links") and the type of those relationships ("link relation types").
本规范定义了Web资源(“链接”)与这些关系类型(“链接关系类型”)之间关系的模型。
HTML [W3C.REC-html5-20141028] and Atom [RFC4287] both have well-defined concepts of linking; Section 2 generalises this into a framework that encompasses linking in these formats and (potentially) elsewhere.
HTML[W3C.REC-html5-20141028]和Atom[RFC4287]都有定义良好的链接概念;第2节将其概括为一个框架,该框架包含这些格式的链接和(可能)其他地方的链接。
Furthermore, Section 3 defines an HTTP header field for conveying such links.
此外,第3节定义了用于传输此类链接的HTTP头字段。
The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in BCP 14 [RFC2119] [RFC8174] when, and only when, they appear in all capitals, as shown here.
本文件中的关键词“必须”、“不得”、“必需”、“应”、“不应”、“建议”、“不建议”、“可”和“可选”在所有大写字母出现时(如图所示)应按照BCP 14[RFC2119][RFC8174]所述进行解释。
This document uses the Augmented Backus-Naur Form (ABNF) [RFC5234] notation of [RFC7230], including the #rule, and explicitly includes the following rules from it: quoted-string, token, SP (space), BWS (bad whitespace), OWS (optional whitespace), RWS (required whitespace), LOALPHA, DIGIT.
本文档使用[RFC7230]的增广巴科斯-诺尔格式(ABNF)[RFC5234]符号,包括#规则,并明确包含以下规则:带引号的字符串、标记、SP(空格)、BWS(坏空格)、OWS(可选空格)、RWS(必需空格)、LOALPHA、数字。
Additionally, the following rules are included:
此外,还包括以下规则:
o URI and URI-Reference from [RFC3986], o type-name and subtype-name from [RFC6838], o media-query-list from [W3C.REC-css3-mediaqueries-20120619], and o Language-Tag from [RFC5646].
o [RFC3986]中的URI和URI引用,[RFC6838]中的o类型名称和子类型名称,[W3C.REC-css3-mediaqueries-20120619]中的o媒体查询列表,[RFC5646]中的o语言标记。
The requirements regarding conformance and error handling highlighted in [RFC7230], Section 2.5 apply to this document.
[RFC7230]第2.5节中强调的关于一致性和错误处理的要求适用于本文件。
In this specification, a link is a typed connection between two resources and is comprised of:
在本规范中,链接是两个资源之间的类型化连接,包括:
o a link context, o a link relation type (Section 2.1), o a link target, and o optionally, target attributes (Section 2.2).
o 链接上下文、链接关系类型(第2.1节)、链接目标和可选的目标属性(第2.2节)。
A link can be viewed as a statement of the form "link context has a link relation type resource at link target, which has target attributes".
链接可以被视为“链接上下文在链接目标处具有链接关系类型资源,该资源具有目标属性”形式的语句。
For example, "https://www.example.com/" has a "canonical" resource at "https://example.com", which has a "type" of "text/html".
例如,”https://www.example.com/在处具有“规范”资源https://example.com,其“类型”为“text/html”。
Link contexts and link targets are both Internationalized Resource Identifiers (IRIs) [RFC3987]. However, in the common case, the link context will also be a URI [RFC3986], because many protocols (such as HTTP) do not support dereferencing IRIs. Likewise, the link target will sometimes be converted to a URI (see [RFC3987], Section 3.1) in serialisations that do not support IRIs (such as the Link header field defined in Section 3).
链接上下文和链接目标都是国际化资源标识符(IRI)[RFC3987]。然而,在常见情况下,链接上下文也将是URI[RFC3986],因为许多协议(如HTTP)不支持对IRIs的解引用。同样,链接目标有时会在不支持IRIs的序列化中转换为URI(参见[RFC3987],第3.1节)(如第3节中定义的链接头字段)。
This specification does not place restrictions on the cardinality of links; there can be multiple links to and from a particular target and multiple links of the same or different types between a given context and target. Likewise, the relative ordering of links in any particular serialisation, or between serialisations (e.g., the Link header field and in-content links), is not specified or significant in this specification; applications that wish to consider ordering significant can do so.
本规范不限制链接的基数;可以有多个指向特定目标的链接,也可以有来自特定目标的链接,以及给定上下文和目标之间相同或不同类型的多个链接。同样,在任何特定序列化中或序列化之间(例如,链接头字段和内容链接中)的链接相对顺序在本规范中未规定或不重要;希望考虑重要性的应用程序可以做到这一点。
Links are conveyed in link serialisations; they are the "bytes on the wire", and can occur in various forms. For example, Atom [RFC4287] and HTML [W3C.REC-html5-20141028] both defined serialisations of links into their respective formats, and Section 3 defines how to serialise links in HTTP header fields.
链接以链接序列的形式传送;它们是“线路上的字节”,可以以各种形式出现。例如,Atom[RFC4287]和HTML[W3C.REC-html5-20141028]都将链接序列化定义为各自的格式,第3节定义了如何在HTTP头字段中序列化链接。
This specification does not define a general syntax for links across different serialisations, nor does it mandate a specific context for any given link; it is expected that serialisations of links will specify both aspects.
本规范没有为跨不同序列化的链接定义通用语法,也没有为任何给定链接指定特定上下文;预期链接的序列化将指定这两个方面。
Finally, links are used by link applications. Generally, an application will define the link relation type(s) it uses, along with the serialisation(s) that they might occur within. For example, the
最后,链接由链接应用程序使用。通常,应用程序将定义它使用的链接关系类型,以及它们可能发生的序列化。例如
application "Web browsing" looks for the "stylesheet" link relation type in the HTML link serialisation (and optionally in the Link header field), whereas the application "AtomPub" uses the "edit" and "edit-media" link relations in the Atom serialisation.
应用程序“Web浏览”在HTML链接序列化(以及可选的链接头字段)中查找“样式表”链接关系类型,而应用程序“AtomPub”在Atom序列化中使用“编辑”和“编辑媒体”链接关系。
In the simplest case, a link relation type identifies the semantics of a link. For example, a link with the relation type "copyright" indicates that the current link context has a copyright resource at the link target.
在最简单的情况下,链接关系类型标识链接的语义。例如,关系类型为“版权”的链接表示当前链接上下文在链接目标处具有版权资源。
Link relation types can also be used to indicate that the target resource has particular attributes, or exhibits particular behaviours; for example, a "service" link implies that the link target can be used as part of a defined protocol (in this case, a service description).
链接关系类型还可用于指示目标资源具有特定属性或表现出特定行为;例如,“服务”链接意味着链接目标可以用作已定义协议的一部分(在本例中为服务描述)。
Relation types are not to be confused with media types [RFC2046]; they do not identify the format of the representation that results when the link is dereferenced. Rather, they only describe how the current context is related to another resource.
关系类型不能与媒体类型混淆[RFC2046];它们不标识链接取消引用时产生的表示形式的格式。相反,它们只描述当前上下文如何与另一个资源相关。
Relation types SHOULD NOT infer any additional semantics based upon the presence or absence of another link relation type, or its own cardinality of occurrence. An exception to this is the combination of the "alternate" and "stylesheet" registered relation types, which has special meaning in HTML for historical reasons.
关系类型不应基于另一个链接关系类型的存在或不存在或其自身的发生基数来推断任何附加语义。例外情况是“alternate”和“stylesheet”注册关系类型的组合,由于历史原因,这在HTML中具有特殊意义。
There are two kinds of relation types: registered and extension.
有两种关系类型:registered和extension。
Well-defined relation types can be registered as tokens for convenience and/or to promote reuse by other applications, using the procedure in Section 2.1.1.1.
使用第2.1.1.1节中的过程,可以将定义良好的关系类型注册为令牌,以方便和/或促进其他应用程序的重用。
Registered relation type names MUST conform to the reg-rel-type rule (see Section 3.3) and MUST be compared character by character in a case-insensitive fashion. They SHOULD be appropriate to the specificity of the relation type; that is, if the semantics are highly specific to a particular application, the name should reflect that, so that more general names are available for less-specific use.
注册的关系类型名称必须符合reg rel type规则(参见第3.3节),并且必须以不区分大小写的方式逐字符进行比较。它们应该适合关系类型的特殊性;也就是说,如果语义非常特定于特定的应用程序,那么名称应该反映这一点,以便更通用的名称可用于不太特定的用途。
Registered relation types MUST NOT constrain the media type of the link context and MUST NOT constrain the available representation media types of the link target. However, they can specify the behaviours and properties of the target resource (e.g., allowable
注册的关系类型不得约束链接上下文的媒体类型,也不得约束链接目标的可用表示媒体类型。但是,它们可以指定目标资源的行为和属性(例如,允许的
HTTP methods, and request and response media types that are required be supported).
HTTP方法以及所需的请求和响应媒体类型(不受支持)。
Historically, registered relation types have been identified with a URI [RFC3986] by prefixing their names with an application-defined base URI (e.g., see Appendix A.2). This practice is NOT RECOMMENDED, because the resulting strings will not be considered equivalent to the registered relation types by other applications. Applications that do use such URIs internally MUST NOT use them in link serialisations that do not explicitly accommodate them.
历史上,已注册的关系类型通过在其名称前面加上应用程序定义的基本URI(例如,参见附录a.2)来用URI[RFC3986]标识。不建议使用这种做法,因为生成的字符串不会被其他应用程序视为等同于已注册的关系类型。在内部使用此类URI的应用程序不得在未显式容纳它们的链接序列化中使用它们。
The "Link Relations" registry is located at <https://www.iana.org/assignments/link-relations/>. Registration requests can be made by following the instructions located there or by sending an email to the <link-relations@ietf.org> mailing list.
“链接关系”注册表位于<https://www.iana.org/assignments/link-relations/>. 注册请求可以按照此处的说明进行,也可以发送电子邮件到<link-relations@ietf.org>邮件列表。
Registration requests consist of at least the following information:
注册请求至少包含以下信息:
o *Relation Name*: The name of the relation type
o *Relation Name*: The name of the relation type
o *Description*: A short English description of the type's semantics. It SHOULD be stated in terms of the relationship between the link context and link target.
o *Description*:类型语义的简短英文描述。应该根据链接上下文和链接目标之间的关系来说明。
o *Reference*: Reference to the document that specifies the link relation type, preferably including a URI that can be used to retrieve a copy of the document. An indication of the relevant section(s) can also be included but is not required.
o *Reference*:对指定链接关系类型的文档的引用,最好包括可用于检索文档副本的URI。也可以包括相关部分的指示,但不是必需的。
The expert(s) can define additional fields to be collected in the registry.
专家可以定义要在注册表中收集的其他字段。
General requirements for registered relation types are described in Section 2.1.1.
注册关系类型的一般要求见第2.1.1节。
Registrations MUST reference a freely available, stable specification.
注册必须参考免费、稳定的规范。
Note that relation types can be registered by third parties (including the expert(s)), if the expert(s) determines that an unregistered relation type is widely deployed and not likely to be registered in a timely manner otherwise. Such registrations still are subject to the requirements defined, including the need to reference a specification.
请注意,如果第三方(包括专家)确定广泛部署了未注册的关系类型,并且不可能及时注册,则第三方(包括专家)可以注册关系类型。此类注册仍受定义要求的约束,包括需要参考规范。
Relation types are registered using the Specification Required policy (see Section 4.6 of [RFC8126]), which implies review and approval by a designated expert.
使用规范要求的政策(参见[RFC8126]第4.6节)注册关系类型,这意味着由指定专家进行审查和批准。
The goal of the registry is to reflect common use of links on the Internet. Therefore, the expert(s) should be strongly biased towards approving registrations, unless they are abusive, frivolous, not likely to be used on the Internet, or actively harmful to the Internet and/or the Web (not merely aesthetically displeasing or architecturally dubious). As stated in Section 2.1.1, the expert(s) can withhold registration of names that are too general for the proposed application.
登记册的目标是反映互联网上链接的普遍使用情况。因此,专家应强烈倾向于批准注册,除非这些注册具有滥用性、轻浮性、不太可能在互联网上使用或对互联网和/或网络有害(不仅仅是在美学上令人不快或在架构上可疑)。如第2.1.1节所述,对于过于笼统的名称,专家可拒绝注册。
The expert(s) will clearly identify any issues that cause a registration to be refused. Advice about the semantics of a proposed link relation type can be given, but if it does not block registration, this should be explicitly stated.
专家将明确识别导致注册被拒绝的任何问题。可以给出建议的链接关系类型的语义建议,但如果它不阻止注册,则应明确说明。
When a request is approved, the expert(s) will inform IANA, and the registration will be processed. The IESG is the final arbiter of any objection.
当请求获得批准时,专家将通知IANA,并处理注册。IESG是任何异议的最终仲裁人。
Applications that don't wish to register a relation type can use an extension relation type, which is a URI [RFC3986] that uniquely identifies the relation type. Although the URI can point to a resource that contains a definition of the semantics of the relation type, clients SHOULD NOT automatically access that resource to avoid overburdening its server.
不希望注册关系类型的应用程序可以使用扩展关系类型,它是唯一标识关系类型的URI[RFC3986]。尽管URI可以指向包含关系类型语义定义的资源,但客户端不应自动访问该资源以避免服务器负担过重。
The URI used for an extension relation type SHOULD be under the control of the person or party defining it or be delegated to them.
用于扩展关系类型的URI应由定义它的人员或参与方控制,或委托给他们。
When extension relation types are compared, they MUST be compared as strings (after converting to URIs if serialised in a different format) in a case-insensitive fashion, character by character. Because of this, all-lowercase URIs SHOULD be used for extension relations.
在比较扩展关系类型时,必须以不区分大小写的方式逐个字符地将它们作为字符串进行比较(如果以不同的格式序列化,则转换为URI之后)。因此,所有小写URI都应该用于扩展关系。
Note that while extension relation types are required to be URIs, a serialisation of links can specify that they are expressed in another form, as long as they can be converted to URIs.
请注意,虽然扩展关系类型必须是URI,但链接的序列化可以指定它们以另一种形式表示,只要它们可以转换为URI即可。
Target attributes are a list of key/value pairs that describe the link or its target; for example, a media type hint.
目标属性是描述链接或其目标的键/值对列表;例如,媒体类型提示。
They can be defined both by individual link relation types and by link serialisations.
它们可以通过单个链接关系类型和链接序列化来定义。
This specification does not attempt to coordinate the name of target attributes, their cardinality, or use. Those creating and maintaining serialisations SHOULD coordinate their target attributes to avoid conflicts in semantics or syntax and MAY define their own registries of target attributes.
本规范不尝试协调目标属性的名称、其基数或用途。创建和维护序列化的人应该协调他们的目标属性,以避免语义或语法上的冲突,并且可以定义他们自己的目标属性注册表。
The names of target attributes SHOULD conform to the token rule, but SHOULD NOT include any of the characters "%", "'", or "*", for portability across serialisations and MUST be compared in a case-insensitive fashion.
目标属性的名称应符合令牌规则,但不应包含任何字符“%”、“%”或“*”,以便跨序列化进行移植,并且必须以不区分大小写的方式进行比较。
Target attribute definitions SHOULD specify:
目标属性定义应指定:
o The serialisation of their values into Unicode or a subset thereof, to maximise their chances of portability across link serialisations. o The semantics and error handling of multiple occurrences of the target attribute on a given link.
o 将其值序列化为Unicode或其子集,以最大限度地提高其跨链接序列化的可移植性。o给定链接上目标属性多次出现的语义和错误处理。
This specification does define target attributes for use in the Link HTTP header field in Section 3.4.
本规范定义了在第3.4节的链接HTTP头字段中使用的目标属性。
The Link header field provides a means for serialising one or more links into HTTP headers.
链接头字段提供了将一个或多个链接序列化为HTTP头的方法。
The ABNF for the field value is:
字段值的ABNF为:
Link = #link-value link-value = "<" URI-Reference ">" *( OWS ";" OWS link-param ) link-param = token BWS [ "=" BWS ( token / quoted-string ) ]
Link = #link-value link-value = "<" URI-Reference ">" *( OWS ";" OWS link-param ) link-param = token BWS [ "=" BWS ( token / quoted-string ) ]
Note that any link-param can be generated with values using either the token or the quoted-string syntax; therefore, recipients MUST be able to parse both forms. In other words, the following parameters are equivalent:
请注意,任何链接参数都可以使用标记或带引号的字符串语法生成;因此,收件人必须能够解析这两个表单。换句话说,以下参数是等效的:
x=y x="y"
x=y x=“y”
Previous definitions of the Link header did not equate the token and quoted-string forms explicitly; the title parameter was always quoted, and the hreflang parameter was always a token. Senders wishing to maximize interoperability will send them in those forms.
以前的链接头定义没有明确地等同于标记和带引号的字符串形式;title参数始终被引用,hreflang参数始终是一个标记。希望最大化互操作性的发送方将以这些形式发送它们。
Individual link-params specify their syntax in terms of the value after any necessary unquoting (as per [RFC7230], Section 3.2.6).
单个链接参数在任何必要的取消引号后,根据值指定其语法(根据[RFC7230],第3.2.6节)。
This specification establishes the link-params "rel", "anchor", and "rev" (which are part of the general link model), as well as "hreflang", "media", "title", "title*", and "type" (which are target attributes defined by the serialisation).
本规范建立了链接参数“rel”、“anchor”和“rev”(属于通用链接模型的一部分),以及“hreflang”、“media”、“title”、“title*”和“type”(由序列化定义的目标属性)。
Each link-value conveys one target IRI as a URI-Reference (after conversion to one, if necessary; see [RFC3987], Section 3.1) inside angle brackets ("<>"). If the URI-Reference is relative, parsers MUST resolve it as per [RFC3986], Section 5. Note that any base IRI appearing in the message's content is not applied.
每个链接值在尖括号(“<>”)内传递一个目标IRI作为URI引用(如有必要,转换为一个后;参见[RFC3987],第3.1节)。如果URI引用是相对的,解析器必须根据[RFC3986]第5节解析它。请注意,不会应用消息内容中出现的任何基本IRI。
By default, the context of a link conveyed in the Link header field is the URL of the representation it is associated with, as defined in [RFC7231], Section 3.1.4.1, and is serialised as a URI.
默认情况下,链接头字段中传递的链接的上下文是与之关联的表示的URL,如[RFC7231]第3.1.4.1节所定义,并序列化为URI。
When present, the anchor parameter overrides this with another URI, such as a fragment of this resource, or a third resource (i.e., when the anchor value is an absolute URI). If the anchor parameter's value is a relative URI, parsers MUST resolve it as per [RFC3986], Section 5. Note that any base URI from the body's content is not applied.
当存在时,锚参数将使用另一个URI(例如此资源的片段)或第三个资源(即,当锚值是绝对URI)覆盖此URI。如果锚参数的值是相对URI,解析器必须根据[RFC3986]第5节解析它。请注意,不会应用主体内容中的任何基本URI。
The ABNF for the "anchor" parameter's value is:
“锚定”参数值的ABNF为:
URI-Reference ; Section 4.1 of [RFC3986]
URI引用;[RFC3986]第4.1节
Link application can choose to ignore links with an anchor parameter. For example, the application in use might not allow the link context to be assigned to a different resource. In such cases, the entire link is to be ignored; link applications MUST NOT process the link without applying the anchor.
链接应用程序可以选择忽略带有锚参数的链接。例如,正在使用的应用程序可能不允许将链接上下文分配给其他资源。在这种情况下,整个链接将被忽略;链接应用程序不得在未应用锚的情况下处理链接。
Note that depending on HTTP status code and response headers, the link context might be "anonymous" (i.e., no link context is available). For example, this is the case on a 404 response to a GET request.
注意,根据HTTP状态代码和响应头,链接上下文可能是“匿名的”(即,没有可用的链接上下文)。例如,对GET请求的404响应就是这种情况。
The relation type of a link conveyed in the Link header field is conveyed in the "rel" parameter's value. The rel parameter MUST be present but MUST NOT appear more than once in a given link-value; occurrences after the first MUST be ignored by parsers.
链接头字段中传输的链接的关系类型在“rel”参数的值中传输。rel参数必须存在,但在给定链接值中不得出现一次以上;解析器必须忽略第一个事件之后出现的事件。
The rel parameter can, however, contain multiple link relation types. When this occurs, it establishes multiple links that share the same context, target, and target attributes.
但是,rel参数可以包含多种链接关系类型。发生这种情况时,它将建立共享相同上下文、目标和目标属性的多个链接。
The "rev" parameter has been used in the past to indicate that the semantics of the relationship are in the reverse direction. That is, a link from A to B with REL="X" expresses the same relationship as a link from B to A with REV="X". rev is deprecated by this specification because it often confuses authors and readers; in most cases, using a separate relation type is preferable.
“rev”参数过去曾被用来表示关系的语义是反向的。也就是说,使用REL=“X”表示从a到B的链接与使用REV=“X”表示从B到a的链接具有相同的关系。本规范不推荐rev,因为它经常混淆作者和读者;在大多数情况下,最好使用单独的关系类型。
The ABNF for the rel and rev parameters' values is:
rel和rev参数值的ABNF为:
relation-type *( 1*SP relation-type )
关系类型*(1*SP关系类型)
where:
哪里:
relation-type = reg-rel-type / ext-rel-type reg-rel-type = LOALPHA *( LOALPHA / DIGIT / "." / "-" ) ext-rel-type = URI ; Section 3 of [RFC3986]
relation-type = reg-rel-type / ext-rel-type reg-rel-type = LOALPHA *( LOALPHA / DIGIT / "." / "-" ) ext-rel-type = URI ; Section 3 of [RFC3986]
Note that extension relation types are REQUIRED to be absolute URIs in Link header fields and MUST be quoted when they contain characters not allowed in tokens, such as a semicolon (";") or comma (",") (as these characters are used as delimiters in the header field itself).
请注意,扩展关系类型必须是链接头字段中的绝对URI,并且当它们包含令牌中不允许使用的字符时,必须使用引号,例如分号(;)或逗号(,)(因为这些字符在头字段本身中用作分隔符)。
The Link header field defines several target attributes specific to this serialisation and also allows extension target attributes. Target attributes are serialised in the Link header field as parameters (see [RFC7231], Section 3.1.1.1 for the definition of their syntax).
链接头字段定义了几个特定于此序列化的目标属性,还允许扩展目标属性。目标属性在链接头字段中作为参数序列化(有关其语法的定义,请参见[RFC7231],第3.1.1.1节)。
The "hreflang", "media", "title", "title*", and "type" link-params can be translated to serialisation-defined target attributes for the link.
“hreflang”、“media”、“title”、“title*”和“type”链接参数可以转换为链接的序列化定义的目标属性。
The "hreflang" attribute, when present, is a hint indicating what the language of the result of dereferencing the link should be. Note that this is only a hint; for example, it does not override the Content-Language header field of a HTTP response obtained by actually following the link. Multiple hreflang attributes on a single link-value indicate that multiple languages are available from the indicated resource.
“hreflang”属性(如果存在)是一个提示,指示取消引用链接的结果的语言应该是什么。请注意,这只是一个提示;例如,它不会覆盖通过实际跟踪链接获得的HTTP响应的Content Language header字段。单个链接值上的多个hreflang属性表示所指示的资源中有多种语言可用。
The ABNF for the hreflang parameter's value is:
hreflang参数值的ABNF为:
Language-Tag
语言标签
The "media" attribute, when present, is used to indicate intended destination medium or media for style information (see [W3C.REC-html5-20141028], Section 4.2.4). Its value MUST be quoted if it contains a semicolon (";") or comma (","). There MUST NOT be more than one media attribute in a link-value; occurrences after the first MUST be ignored by parsers.
“媒体”属性(如果存在)用于指示预期的目标媒体或样式信息的媒体(参见[W3C.REC-html5-20141028],第4.2.4节)。如果它包含分号(;)或逗号(,),则必须将其值引用。链接值中不能有多个媒体属性;解析器必须忽略第一个事件之后出现的事件。
The ABNF for the media parameter's value is:
介质参数值的ABNF为:
media-query-list
媒体查询列表
The "title" attribute, when present, is used to label the destination of a link such that it can be used as a human-readable identifier (e.g., a menu entry) in the language indicated by the Content-Language header field (if present). The title attribute MUST NOT appear more than once in a given link; occurrences after the first MUST be ignored by parsers.
“title”属性(当存在时)用于标记链接的目的地,以使其可用作内容语言标题字段(如果存在)指示的语言中的人类可读标识符(例如,菜单项)。标题属性在给定链接中不得出现多次;解析器必须忽略第一个事件之后出现的事件。
The "title*" link-param can be used to encode this attribute in a different character set and/or contain language information as per [RFC8187]. The title* link-param MUST NOT appear more than once in a given link-value; occurrences after the first MUST be ignored by parsers. If the attribute does not contain language information, its language is indicated by the Content-Language header field (when present).
根据[RFC8187],可以使用“title*”链接参数在不同的字符集中对该属性进行编码和/或包含语言信息。title*link参数在给定链接值中不得出现多次;解析器必须忽略第一个事件之后出现的事件。如果属性不包含语言信息,则其语言由内容语言标题字段(如果存在)指示。
If both the title and title* link-params appear in a link, applications SHOULD use the title* link-param's value for the title attribute.
如果title和title*link参数都出现在链接中,则应用程序应使用title*link参数的值作为title属性。
The "type" attribute, when present, is a hint indicating what the media type of the result of dereferencing the link should be. Note that this is only a hint; for example, it does not override the Content-Type header field of a HTTP response obtained by actually
“type”属性(如果存在)是一个提示,指示取消引用链接的结果的媒体类型。请注意,这只是一个提示;例如,它不会覆盖由用户实际获取的HTTP响应的内容类型头字段
following the link. The type attribute MUST NOT appear more than once in a given link-value; occurrences after the first MUST be ignored by parsers.
点击链接。类型属性在给定链接值中不得出现多次;解析器必须忽略第一个事件之后出现的事件。
The ABNF for the type parameter's value is:
类型参数值的ABNF为:
type-name "/" subtype-name ; see Section 4.2 of [RFC6838]
类型名称“/”子类型名称;见[RFC6838]第4.2节
Other link-params are link-extensions and are to be considered as target attributes.
其他链接参数是链接扩展,将被视为目标属性。
Such target attributes MAY be defined to use the encoding in [RFC8187] (e.g., "example" and "example*"). When both forms are present, they SHOULD be considered to be the same target attribute; applications SHOULD use the value of the name ending in "*" (after [RFC8187] decoding) but MAY fall back to the other value if there is an error in decoding it, or if they do not support decoding.
此类目标属性可定义为使用[RFC8187]中的编码(例如,“示例”和“示例*”)。当两种形式都存在时,应将其视为相同的目标属性;应用程序应使用以“*”(在[RFC8187]解码之后)结尾的名称值,但如果解码时出错或不支持解码,则可能会返回到另一个值。
For example:
例如:
Link: <http://example.com/TheBook/chapter2>; rel="previous"; title="previous chapter"
Link: <http://example.com/TheBook/chapter2>; rel="previous"; title="previous chapter"
indicates that "chapter2" is previous to this resource in a logical navigation path.
指示“chapter2”位于逻辑导航路径中此资源的前面。
Similarly,
同样地,
Link: </>; rel="http://example.net/foo"
Link: </>; rel="http://example.net/foo"
indicates that the root resource ("/") is related to this resource with the extension relation type "http://example.net/foo".
指示根资源(“/”)与扩展关系类型为“”的此资源相关http://example.net/foo".
This link:
此链接:
Link: </terms>; rel="copyright"; anchor="#foo"
Link: </terms>; rel="copyright"; anchor="#foo"
indicates that the linked copyright terms only apply to the portion of the document indicated by the (media type-specific) fragment identifier "foo".
表示链接的版权条款仅适用于(媒体类型特定)片段标识符“foo”指示的文档部分。
The example below shows an instance of the Link header field encoding multiple links and also the use of the encoding from RFC 8187 to encode both non-ASCII characters and language information.
下面的示例显示了链接头字段对多个链接进行编码的实例,以及使用RFC 8187中的编码对非ASCII字符和语言信息进行编码的情况。
Link: </TheBook/chapter2>; rel="previous"; title*=UTF-8'de'letztes%20Kapitel, </TheBook/chapter4>; rel="next"; title*=UTF-8'de'n%c3%a4chstes%20Kapitel
Link: </TheBook/chapter2>; rel="previous"; title*=UTF-8'de'letztes%20Kapitel, </TheBook/chapter4>; rel="next"; title*=UTF-8'de'n%c3%a4chstes%20Kapitel
Here, both links have titles encoded in UTF-8, both use the German language ("de"), and the second link contains the Unicode code point U+00E4 ("LATIN SMALL LETTER A WITH DIAERESIS").
这里,两个链接的标题都用UTF-8编码,都使用德语(“de”),第二个链接包含Unicode代码点U+00E4(“带分音符的拉丁小写字母A”)。
Note that link-values can convey multiple links between the same link target and link context; for example:
注意,链接值可以在同一链接目标和链接上下文之间传递多个链接;例如:
Link: <http://example.org/>; rel="start http://example.net/relation/other"
Link: <http://example.org/>; rel="start http://example.net/relation/other"
Here, the link to "http://example.org/" has the registered relation type "start" and the extension relation type "http://example.net/relation/other".
在这里,链接到“http://example.org/具有注册关系类型“开始”和扩展关系类型http://example.net/relation/other".
Finally, this header field:
最后,此标题字段:
Link: <https://example.org/>; rel="start", <https://example.org/index>; rel="index"
Link: <https://example.org/>; rel="start", <https://example.org/index>; rel="index"
is equivalent to these:
相当于:
Link: <https://example.org/>; rel="start" Link: <https://example.org/index>; rel="index"
Link: <https://example.org/>; rel="start" Link: <https://example.org/index>; rel="index"
This specification updates the "Message Headers" registry entry for "Link" in HTTP [RFC3864] to refer to this document.
本规范更新了HTTP[RFC3864]中“链接”的“消息头”注册表项,以参考本文档。
Header Field Name: Link Protocol: http Status: standard Reference: RFC 8288
标题字段名称:链接协议:http状态:标准参考:RFC 8288
This specification updates the registration procedures for the "Link Relation Types" registry; see Section 2.1.1.1. Also, all references to RFC 5988 in that registry have been replaced with references to this document.
本规范更新了“链接关系类型”注册表的注册程序;见第2.1.1.1节。此外,该注册表中对RFC 5988的所有引用均已替换为对本文件的引用。
IANA will direct any incoming requests regarding the registry to this document and, if defined, the processes established by the expert(s); typically, this will mean referring them to the registry Web page.
IANA将指导任何关于注册中心的传入请求,如有定义,则指导专家建立的流程;通常,这意味着将它们引用到注册表网页。
Note that the expert(s) is allowed (as per Section 2.1.1.1) to define additional fields to be collected in the registry.
请注意,允许专家(根据第2.1.1.1节)定义要在注册表中收集的其他字段。
Per this specification, IANA has removed the "Link Relation Application Data" registry, as it has not been used, and future use is not anticipated.
根据本规范,IANA已经删除了“链接关系应用程序数据”注册表,因为该注册表尚未使用,未来也不会使用。
The content of the Link header field is not secure, private, or integrity-guaranteed. Use of Transport Layer Security (TLS) with HTTP [RFC2818] is currently the only end-to-end way to provide these properties.
链接头字段的内容不安全、不私有或不保证完整性。将传输层安全性(TLS)与HTTP[RFC2818]结合使用是目前提供这些属性的唯一端到端方式。
Link applications ought to consider the attack vectors opened by automatically following, trusting, or otherwise using links gathered from HTTP header fields.
链接应用程序应该考虑通过自动跟踪、信任或以其他方式使用从HTTP报头字段收集的链接来打开攻击向量。
For example, Link header fields that use the "anchor" parameter to associate a link's context with another resource cannot be trusted since they are effectively assertions by a third party that could be incorrect or malicious. Applications can mitigate this risk by specifying that such links should be discarded unless some relationship between the resources is established (e.g., they share the same authority).
例如,使用“anchor”参数将链接上下文与另一资源关联的链接头字段是不可信的,因为它们实际上是第三方的断言,可能是不正确的或恶意的。应用程序可以通过指定除非资源之间建立了某种关系(例如,它们共享相同的权限),否则应丢弃此类链接来降低此风险。
Dereferencing links has a number of risks, depending on the application in use. For example, the Referer header [RFC7231] can expose information about the application's state (including private information) in its value. Likewise, cookies [RFC6265] are another mechanism that, if used, can become an attack vector. Applications can mitigate these risks by carefully specifying how such mechanisms should operate.
根据所使用的应用程序,取消引用链接有许多风险。例如,Referer头[RFC7231]可以在其值中公开有关应用程序状态的信息(包括私有信息)。同样,Cookies [RCF6265]是另一种机制,如果使用,它可以成为攻击向量。应用程序可以通过仔细指定这些机制应该如何运行来降低这些风险。
The Link header field makes extensive use of IRIs and URIs. See [RFC3987], Section 8 for security considerations relating to IRIs. See [RFC3986], Section 7 for security considerations relating to URIs. See [RFC7230], Section 9 for security considerations relating to HTTP header fields.
链接头字段广泛使用IRIs和URI。有关IRIs的安全注意事项,请参见[RFC3987]第8节。有关URI的安全注意事项,请参见[RFC3986]第7节。有关HTTP头字段的安全注意事项,请参见[RFC7230],第9节。
Link targets may need to be converted to URIs in order to express them in serialisations that do not support IRIs. This includes the Link HTTP header field.
链接目标可能需要转换为URI,以便在不支持IRIs的序列化中表示它们。这包括链接HTTP头字段。
Similarly, the anchor parameter of the Link header field does not support IRIs; therefore, IRIs must be converted to URIs before inclusion there.
同样,链接头字段的锚参数不支持IRIs;因此,在包含IRI之前,必须将其转换为URI。
Relation types are defined as URIs, not IRIs, to aid in their comparison. It is not expected that they will be displayed to end users.
关系类型定义为URI,而不是IRI,以帮助进行比较。预计它们不会显示给最终用户。
Note that registered Relation Names are required to be lowercase ASCII letters.
请注意,注册的关系名称必须是小写ASCII字母。
[RFC2119] Bradner, S., "Key words for use in RFCs to Indicate Requirement Levels", BCP 14, RFC 2119, DOI 10.17487/RFC2119, March 1997, <https://www.rfc-editor.org/info/rfc2119>.
[RFC2119]Bradner,S.,“RFC中用于表示需求水平的关键词”,BCP 14,RFC 2119,DOI 10.17487/RFC2119,1997年3月<https://www.rfc-editor.org/info/rfc2119>.
[RFC3864] Klyne, G., Nottingham, M., and J. Mogul, "Registration Procedures for Message Header Fields", BCP 90, RFC 3864, DOI 10.17487/RFC3864, September 2004, <https://www.rfc-editor.org/info/rfc3864>.
[RFC3864]Klyne,G.,Nottingham,M.和J.Mogul,“消息头字段的注册程序”,BCP 90,RFC 3864,DOI 10.17487/RFC3864,2004年9月<https://www.rfc-editor.org/info/rfc3864>.
[RFC3986] Berners-Lee, T., Fielding, R., and L. Masinter, "Uniform Resource Identifier (URI): Generic Syntax", STD 66, RFC 3986, DOI 10.17487/RFC3986, January 2005, <https://www.rfc-editor.org/info/rfc3986>.
[RFC3986]Berners Lee,T.,Fielding,R.,和L.Masinter,“统一资源标识符(URI):通用语法”,STD 66,RFC 3986,DOI 10.17487/RFC3986,2005年1月<https://www.rfc-editor.org/info/rfc3986>.
[RFC3987] Duerst, M. and M. Suignard, "Internationalized Resource Identifiers (IRIs)", RFC 3987, DOI 10.17487/RFC3987, January 2005, <https://www.rfc-editor.org/info/rfc3987>.
[RFC3987]Duerst,M.和M.Suignard,“国际化资源标识符(IRIs)”,RFC 3987,DOI 10.17487/RFC3987,2005年1月<https://www.rfc-editor.org/info/rfc3987>.
[RFC5234] Crocker, D., Ed. and P. Overell, "Augmented BNF for Syntax Specifications: ABNF", STD 68, RFC 5234, DOI 10.17487/RFC5234, January 2008, <https://www.rfc-editor.org/info/rfc5234>.
[RFC5234]Crocker,D.,Ed.和P.Overell,“语法规范的扩充BNF:ABNF”,STD 68,RFC 5234,DOI 10.17487/RFC5234,2008年1月<https://www.rfc-editor.org/info/rfc5234>.
[RFC5646] Phillips, A., Ed. and M. Davis, Ed., "Tags for Identifying Languages", BCP 47, RFC 5646, DOI 10.17487/RFC5646, September 2009, <https://www.rfc-editor.org/info/rfc5646>.
[RFC5646]Phillips,A.,Ed.和M.Davis,Ed.,“识别语言的标签”,BCP 47,RFC 5646,DOI 10.17487/RFC5646,2009年9月<https://www.rfc-editor.org/info/rfc5646>.
[RFC6838] Freed, N., Klensin, J., and T. Hansen, "Media Type Specifications and Registration Procedures", BCP 13, RFC 6838, DOI 10.17487/RFC6838, January 2013, <https://www.rfc-editor.org/info/rfc6838>.
[RFC6838]Freed,N.,Klensin,J.和T.Hansen,“介质类型规范和注册程序”,BCP 13,RFC 6838,DOI 10.17487/RFC6838,2013年1月<https://www.rfc-editor.org/info/rfc6838>.
[RFC7230] Fielding, R., Ed. and J. Reschke, Ed., "Hypertext Transfer Protocol (HTTP/1.1): Message Syntax and Routing", RFC 7230, DOI 10.17487/RFC7230, June 2014, <https://www.rfc-editor.org/info/rfc7230>.
[RFC7230]Fielding,R.,Ed.和J.Reschke,Ed.,“超文本传输协议(HTTP/1.1):消息语法和路由”,RFC 7230,DOI 10.17487/RFC7230,2014年6月<https://www.rfc-editor.org/info/rfc7230>.
[RFC7231] Fielding, R., Ed. and J. Reschke, Ed., "Hypertext Transfer Protocol (HTTP/1.1): Semantics and Content", RFC 7231, DOI 10.17487/RFC7231, June 2014, <https://www.rfc-editor.org/info/rfc7231>.
[RFC7231]Fielding,R.,Ed.和J.Reschke,Ed.,“超文本传输协议(HTTP/1.1):语义和内容”,RFC 7231,DOI 10.17487/RFC72312014年6月<https://www.rfc-editor.org/info/rfc7231>.
[RFC8126] Cotton, M., Leiba, B., and T. Narten, "Guidelines for Writing an IANA Considerations Section in RFCs", BCP 26, RFC 8126, DOI 10.17487/RFC8126, June 2017, <https://www.rfc-editor.org/info/rfc8126>.
[RFC8126]Cotton,M.,Leiba,B.,和T.Narten,“在RFC中编写IANA考虑事项部分的指南”,BCP 26,RFC 8126,DOI 10.17487/RFC8126,2017年6月<https://www.rfc-editor.org/info/rfc8126>.
[RFC8174] Leiba, B., "Ambiguity of Uppercase vs Lowercase in RFC 2119 Key Words", BCP 14, RFC 8174, DOI 10.17487/RFC8174, May 2017, <https://www.rfc-editor.org/info/rfc8174>.
[RFC8174]Leiba,B.,“RFC 2119关键词中大写与小写的歧义”,BCP 14,RFC 8174,DOI 10.17487/RFC8174,2017年5月<https://www.rfc-editor.org/info/rfc8174>.
[RFC8187] Reschke, J., "Indicating Character Encoding and Language for HTTP Header Field Parameters", RFC 8187, DOI 10.17487/RFC8187, September 2017, <https://www.rfc-editor.org/info/rfc8187>.
[RFC8187]Reschke,J.“指示HTTP头字段参数的字符编码和语言”,RFC 8187,DOI 10.17487/RFC8187,2017年9月<https://www.rfc-editor.org/info/rfc8187>.
[W3C.REC-css3-mediaqueries-20120619] Rivoal, F., "Media Queries", W3C Recommendation REC-css3-mediaqueries-20120619, June 2012, <http://www.w3.org/TR/2012/ REC-css3-mediaqueries-20120619>.
[W3C.REC-css3-mediaqueries-20120619]Rivoal,F.,“媒体查询”,W3C建议REC-css3-mediaqueries-201206192012年6月<http://www.w3.org/TR/2012/ REC-css3-mediaqueries-20120619>。
[RFC2046] Freed, N. and N. Borenstein, "Multipurpose Internet Mail Extensions (MIME) Part Two: Media Types", RFC 2046, DOI 10.17487/RFC2046, November 1996, <https://www.rfc-editor.org/info/rfc2046>.
[RFC2046]Freed,N.和N.Borenstein,“多用途互联网邮件扩展(MIME)第二部分:媒体类型”,RFC 2046,DOI 10.17487/RFC2046,1996年11月<https://www.rfc-editor.org/info/rfc2046>.
[RFC2818] Rescorla, E., "HTTP Over TLS", RFC 2818, DOI 10.17487/RFC2818, May 2000, <https://www.rfc-editor.org/info/rfc2818>.
[RFC2818]Rescorla,E.,“TLS上的HTTP”,RFC 2818,DOI 10.17487/RFC2818,2000年5月<https://www.rfc-editor.org/info/rfc2818>.
[RFC4287] Nottingham, M., Ed. and R. Sayre, Ed., "The Atom Syndication Format", RFC 4287, DOI 10.17487/RFC4287, December 2005, <https://www.rfc-editor.org/info/rfc4287>.
[RFC4287]诺丁汉,M.,Ed.和R.Sayre,Ed.,“原子联合格式”,RFC 4287,DOI 10.17487/RFC4287,2005年12月<https://www.rfc-editor.org/info/rfc4287>.
[RFC6265] Barth, A., "HTTP State Management Mechanism", RFC 6265, DOI 10.17487/RFC6265, April 2011, <https://www.rfc-editor.org/info/rfc6265>.
[RFC6265]Barth,A.,“HTTP状态管理机制”,RFC 6265,DOI 10.17487/RFC6265,2011年4月<https://www.rfc-editor.org/info/rfc6265>.
[W3C.REC-html5-20141028] Hickson, I., Berjon, R., Faulkner, S., Leithead, T., Navara, E., O'Connor, T., and S. Pfeiffer, "HTML5", W3C Recommendation REC-html5-20141028, October 2014, <http://www.w3.org/TR/2014/REC-html5-20141028>.
[W3C.REC-html5-20141028]希克森,I.,伯容,R.,福克纳,S.,莱塞德,T.,纳瓦拉,E.,O'Connor,T.,和S.Pfeiffer,“html5”,W3C建议REC-html5-20141028,2014年10月<http://www.w3.org/TR/2014/REC-html5-20141028>.
Header fields (Section 3) are only one serialisation of links; other specifications have defined alternative serialisations.
标题字段(第3节)只是链接的一种序列化;其他规范定义了可选的序列化。
HTML motivated the original syntax of the Link header field, and many of the design decisions in this document are driven by a desire to stay compatible with it.
HTML激发了链接头字段的原始语法,本文档中的许多设计决策都是出于与之兼容的愿望。
In HTML, the link element can be mapped to links as specified here by using the "href" attribute for the target URI, and "rel" to convey the relation type, as in the Link header field. The context of the link is the URI associated with the entire HTML document. HTML also defines several attributes on links that can be seen as target attributes, including "media", "hreflang", "type", and "sizes".
在HTML中,链接元素可以映射到此处指定的链接,方法是使用目标URI的“href”属性和“rel”来传递关系类型,如链接头字段中所示。链接的上下文是与整个HTML文档关联的URI。HTML还定义了链接上的几个属性,这些属性可以被视为目标属性,包括“媒体”、“hreflang”、“类型”和“大小”。
Section 4.8 of HTML5 [W3C.REC-html5-20141028] defines modern HTML links. That document links to the Microformats Wiki as a registry; over time, the IANA registry ought to mirror its contents and, ideally, eventually replace it (although that depends on the HTML community).
HTML5[W3C.REC-HTML5-20141028]第4.8节定义了现代HTML链接。该文档链接到微格式Wiki作为注册表;随着时间的推移,IANA注册中心应该镜像它的内容,并在理想情况下最终替换它(尽管这取决于HTML社区)。
Surveys of existing HTML content have shown that unregistered link relation types that are not URIs are (perhaps inevitably) common. Consuming HTML implementations ought not consider such unregistered short links to be errors, but rather relation types with a local scope (i.e., their meaning is specific and perhaps private to that document).
对现有HTML内容的调查表明,非URI的未注册链接关系类型(可能不可避免)很常见。使用HTML实现不应该认为这种未注册的短链接是错误的,而是关系类型与局部范围(即,它们的含义是特定的并且可能是私有的)。
Finally, the HTML specification gives a special meaning when the "alternate" relation types coincide with other relation types in the same link. Such links ought to be serialised in the Link header field using a single list of relation-types (e.g., rel="alternate stylesheet") to preserve this relationship.
最后,当“备用”关系类型与同一链接中的其他关系类型一致时,HTML规范给出了一个特殊的含义。此类链接应该在链接头字段中使用单一关系类型列表(例如rel=“alternate stylesheet”)序列化,以保留此关系。
Atom [RFC4287] is a link serialisation that conveys links in the atom:link element, with the "href" attribute indicating the link target and the "rel" attribute containing the relation type. The context of the link is either a feed locator or an entry ID, depending on where it appears; generally, feed-level links are obvious candidates for transmission as a Link header field.
Atom[RFC4287]是一种链接序列化,它在Atom:link元素中传递链接,“href”属性表示链接目标,“rel”属性包含关系类型。链接的上下文是提要定位器或条目ID,具体取决于它出现的位置;通常,馈送级链路是作为链路头字段传输的明显候选。
When serialising an atom:link into a Link header field, it is necessary to convert link targets (if used) to URIs.
将atom:link序列化为link header字段时,需要将链接目标(如果使用)转换为URI。
Atom defines extension relation types in terms of IRIs. This specification redefines them as URIs, to simplify and reduce errors in their comparison.
Atom根据IRI定义扩展关系类型。该规范将它们重新定义为URI,以简化和减少比较中的错误。
Atom allows registered link relation types to be serialised as absolute URIs using a prefix, "http://www.iana.org/assignments/ relation/". This prefix is specific to the Atom serialisation.
Atom允许使用前缀将已注册的链接关系类型序列化为绝对URIhttp://www.iana.org/assignments/ 关系/”。此前缀特定于Atom序列化。
Furthermore, link relation types are always compared in a case-sensitive fashion; therefore, registered link relation types SHOULD be converted to their registered form (usually, lowercase) when serialised in an Atom document.
此外,链接关系类型总是以区分大小写的方式进行比较;因此,在Atom文档中序列化时,应将已注册的链接关系类型转换为其已注册的形式(通常为小写)。
Note also that while the Link header field allows multiple relations to be serialised in a single link, atom:link does not. In this case, a single link-value may map to several atom:link elements.
还请注意,虽然linkheader字段允许在单个链接中序列化多个关系,但atom:Link不允许。在这种情况下,单个链接值可能映射到多个atom:link元素。
As with HTML, atom:link defines some attributes that are not explicitly mirrored in the Link header field syntax, but they can also be used as link-extensions to maintain fidelity.
与HTML一样,atom:link定义了一些未在链接头字段语法中显式镜像的属性,但它们也可以用作链接扩展以保持逼真度。
This appendix outlines a set of non-normative algorithms: for parsing the Link header(s) out of a header set, for parsing a Link header field value, and algorithms for parsing generic parts of the field value.
本附录概述了一组非规范性算法:用于解析标题集中的链接标题,用于解析链接标题字段值,以及解析字段值的通用部分的算法。
These algorithms are more permissive than the ABNF defining the syntax might suggest; the error handling embodied in them is a reasonable approach, but not one that is required. As such they are advisory only, and in cases where there is disagreement, the correct behaviour is defined by the body of this specification.
这些算法比ABNF定义语法的建议更为宽松;其中包含的错误处理是一种合理的方法,但不是必需的方法。因此,它们只是建议性的,在存在分歧的情况下,正确的行为由本规范主体定义。
This algorithm can be used to parse the Link header fields that a HTTP header set contains. Given a header_set of (string field_name, string field_value) pairs, assuming ASCII encoding, it returns a list of link objects.
此算法可用于解析HTTP标头集包含的链接标头字段。给定(字符串字段名称、字符串字段值)对的标题集,假设采用ASCII编码,它将返回链接对象列表。
1. Let field_values be a list containing the members of header_set whose field_name is a case-insensitive match for "link".
1. 让field_值成为一个列表,其中包含header_集合的成员,其field_名称与“link”匹配,不区分大小写。
2. Let links be an empty list.
2. 让链接成为空列表。
3. For each field_value in field_values: 1. Let value_links be the result of Parsing a Link Field Value (Appendix B.2) from field_value. 2. Append each member of value_links to links.
3. 对于字段_值中的每个字段_值:1。让value_links作为从Field_value解析链接字段值(附录B.2)的结果。2.将值链接的每个成员附加到链接。
4. Return links.
4. 返回链接。
This algorithm parses zero or more comma-separated link-values from a Link header field. Given a string field_value, assuming ASCII encoding, it returns a list of link objects.
此算法从链接头字段解析零个或多个逗号分隔的链接值。给定字符串字段_值,假设采用ASCII编码,它将返回链接对象列表。
1. Let links be an empty list.
1. 让链接成为空列表。
2. While field_value has content: 1. Consume any leading OWS. 2. If the first character is not "<", return links. 3. Discard the first character ("<"). 4. Consume up to but not including the first ">" character or end of field_value and let the result be target_string. 5. If the next character is not ">", return links. 6. Discard the leading ">" character. 7. Let link_parameters be the result of Parsing Parameters (Appendix B.3) from field_value (consuming zero or more characters of it). 8. Let target_uri be the result of relatively resolving (as per [RFC3986], Section 5.2) target_string. Note that any base URI carried in the payload body is NOT used. 9. Let relations_string be the second item of the first tuple of link_parameters whose first item matches the string "rel" or the empty string ("") if it is not present. 10. Split relations_string on RWS (removing it in the process) into a list of string relation_types. 11. Let context_string be the second item of the first tuple of link_parameters whose first item matches the string "anchor". If it is not present, context_string is the URL of the representation carrying the Link header [RFC7231], Section 3.1.4.1, serialised as a URI. Where the URL is anonymous, context_string is null. 12. Let context_uri be the result of relatively resolving (as per [RFC3986], Section 5.2) context_string, unless context_string is null, in which case context is null. Note that any base URI carried in the payload body is NOT used. 13. Let target_attributes be an empty list.
2. 而字段_值的内容为:1。消耗任何领先的OWS。2.如果第一个字符不是“<”,则返回链接。3.放弃第一个字符(“<”)。4.使用最多但不包括第一个“>”字符或字段\u值的结尾,并将结果设为目标\u字符串。5.如果下一个字符不是“>”,则返回链接。6.丢弃前导“>”字符。7.让link_参数是从字段_值(使用零个或多个字符)解析参数(附录B.3)的结果。8.让target_uri为相对解析(根据[RFC3986]第5.2节)target_字符串的结果。请注意,不使用有效负载主体中携带的任何基本URI。9让relations_string作为link_参数的第一个元组的第二项,其第一项与字符串“rel”或空字符串(“”)匹配(如果不存在)。10将RWS上的关系\u字符串(在过程中删除)拆分为字符串关系\u类型列表。11让context_string成为link_参数的第一个元组的第二项,其第一项与字符串“anchor”匹配。如果不存在,则context_string是包含链接头[RFC7231],第3.1.4.1节,序列化为URI的表示的URL。如果URL是匿名的,则上下文字符串为空。12让context_uri是相对解析(根据[RFC3986]第5.2节)context_字符串的结果,除非context_字符串为null,在这种情况下context为null。请注意,不使用有效负载主体中携带的任何基本URI。13让target_属性为空列表。
14. For each tuple (param_name, param_value) of link_parameters: 1. If param_name matches "rel" or "anchor", skip this tuple. 2. If param_name matches "media", "title", "title*", or "type" and target_attributes already contains a tuple whose first element matches the value of param_name, skip this tuple. 3. Append (param_name, param_value) to target_attributes. 15. Let star_param_names be the set of param_names in the (param_name, param_value) tuples of link_parameters where the last character of param_name is an asterisk ("*"). 16. For each star_param_name in star_param_names: 1. Let base_param_name be star_param_name with the last character removed. 2. If the implementation does not choose to support an internationalised form of a parameter named base_param_name for any reason (including, but not limited to, it being prohibited by the parameter's specification), remove all tuples from link_parameters whose first member is star_param_name, and skip to the next star_param_name. 3. Remove all tuples from link_parameters whose first member is base_param_name. 4. Change the first member of all tuples in link_parameters whose first member is star_param_name to base_param_name. 17. For each relation_type in relation_types: 1. Case-normalise relation_type to lowercase. 2. Append a link object to links with the target target_uri, relation type of relation_type, context of context_uri, and target attributes target_attributes.
14. 对于link_参数的每个元组(param_name,param_value):1。如果参数名称与“rel”或“anchor”匹配,则跳过此元组。2.如果param_name与“media”、“title”、“title*”或“type”匹配,并且target_属性已包含其第一个元素与param_name的值匹配的元组,则跳过此元组。3.将(参数名称、参数值)附加到目标属性。15设star_param_names为link_参数(param_name,param_value)元组中的一组param_名称,其中param_name的最后一个字符为星号(“*”)。16对于星号参数名称中的每个星号参数名称:1。让base_param_name为star_param_name,删除最后一个字符。2.如果实现出于任何原因(包括但不限于参数规范禁止)不选择支持名为base_param_name的参数的国际化形式,请从link_参数中删除第一个成员为star_param_name的所有元组,并跳到下一个star_param_name。3.从第一个成员为base_param_name的link_参数中删除所有元组。4.将link_参数中第一个成员为star_param_name的所有元组的第一个成员更改为base_param_name。17对于关系类型中的每个关系类型:1。将大小写关系规格化为小写。2.将链接对象附加到具有目标target_uri、关系类型的关系类型、上下文uri的上下文和目标属性target_属性的链接。
3. Return links.
3. 返回链接。
This algorithm parses the parameters from a header field value. Given input, an ASCII string, it returns a list of (string parameter_name, string parameter_value) tuples that it contains. input is modified to remove the parsed parameters.
此算法从标头字段值解析参数。给定输入,一个ASCII字符串,它返回它包含的(字符串参数\名称,字符串参数\值)元组列表。修改输入以删除已解析的参数。
1. Let parameters be an empty list.
1. 让参数为空列表。
2. While input has content: 1. Consume any leading OWS. 2. If the first character is not ";", return parameters. 3. Discard the leading ";" character. 4. Consume any leading OWS.
2. 而输入有内容:1。消耗任何领先的OWS。2.如果第一个字符不是“;”,则返回参数。3.丢弃前导“;”字符。4.消耗任何领先的OWS。
5. Consume up to but not including the first BWS, "=", ";", or "," character, or up to the end of input, and let the result be parameter_name. 6. Consume any leading BWS. 7. If the next character is "=": 1. Discard the leading "=" character. 2. Consume any leading BWS. 3. If the next character is DQUOTE, let parameter_value be the result of Parsing a Quoted String (Appendix B.4) from input (consuming zero or more characters of it). 4. Else, consume the contents up to but not including the first ";" or "," character, or up to the end of input, and let the results be parameter_value. 5. If the last character of parameter_name is an asterisk ("*"), decode parameter_value according to [RFC8187]. Continue processing input if an unrecoverable error is encountered. 8. Else: 1. Let parameter_value be an empty string. 9. Case-normalise parameter_name to lowercase. 10. Append (parameter_name, parameter_value) to parameters. 11. Consume any leading OWS. 12. If the next character is "," or the end of input, stop processing input and return parameters.
5. 使用最多但不包括第一个BWS,“=”、“;”或“,”字符,或直到输入结束,并将结果设为参数_name。6.消耗任何领先的BW。7.如果下一个字符为“=”:1。丢弃前导“=”字符。2.消耗任何领先的BW。3.如果下一个字符是DQUOTE,则参数_值应为从输入(使用零个或多个字符)解析带引号字符串(附录B.4)的结果。4.否则,使用直到但不包括第一个“;”或“,”字符的内容,或直到输入结束的内容,并让结果为参数值。5.如果参数_name的最后一个字符是星号(“*”),则根据[RFC8187]对参数_值进行解码。如果遇到不可恢复的错误,请继续处理输入。8.其他:1。让参数_值为空字符串。9将参数名称大小写规范化为小写。10将(参数名称、参数值)附加到参数。11消耗任何领先的OWS。12如果下一个字符是“,”或输入结束,则停止处理输入并返回参数。
This algorithm parses a quoted string, as per [RFC7230], Section 3.2.6. Given input, an ASCII string, it returns an unquoted string. input is modified to remove the parsed string.
该算法根据[RFC7230]第3.2.6节解析带引号的字符串。给定一个ASCII字符串作为输入,它返回一个不带引号的字符串。修改输入以删除已解析的字符串。
1. Let output be an empty string.
1. 让输出为空字符串。
2. If the first character of input is not DQUOTE, return output.
2. 如果输入的第一个字符不是DQUOTE,则返回输出。
3. Discard the first character.
3. 丢弃第一个字符。
4. While input has content: 1. If the first character is a backslash ("\"): 1. Discard the first character. 2. If there is no more input, return output. 3. Else, consume the first character and append it to output. 2. Else, if the first character is DQUOTE, discard it and return output. 3. Else, consume the first character and append it to output.
4. 而输入有内容:1。如果第一个字符是反斜杠(\):1。丢弃第一个字符。2.如果没有更多的输入,则返回输出。3.否则,使用第一个字符并将其附加到输出。2.否则,如果第一个字符是DQUOTE,则放弃它并返回输出。3.否则,使用第一个字符并将其附加到输出。
5. Return output.
5. 返回输出。
This specification has the following differences from its predecessor, RFC 5988:
本规范与其前身RFC 5988有以下区别:
o The initial relation type registrations were removed, since they've already been registered by RFC 5988. o The introduction has been shortened. o The "Link Relation Application Data" registry has been removed. o Incorporated errata. o Updated references. o Link cardinality was clarified. o Terminology was changed from "target IRI" and "context IRI" to "link target" and "link context", respectively. o Made assigning a URI to registered relation types serialisation specific. o Removed misleading statement that the Link header field is semantically equivalent to HTML and Atom links. o More carefully defined and used "link serialisations" and "link applications." o Clarified the cardinality of target attributes (generically and for "type"). o Corrected the default link context for the Link header field, to be dependent upon the identity of the representation (as per RFC 7231). o Defined a suggested parsing algorithm for the Link header. o The value space of target attributes and their definition has been specified. o The ABNF has been updated to be compatible with [RFC7230]. In particular, whitespace is now explicit. o Some parameters on the HTTP header field can now appear as a token. o Parameters on the HTTP header can now be valueless. o Handling of quoted strings is now defined by [RFC7230]. o The "type" header field parameter now needs to be quoted (as "token" does not allow "/").
o 初始关系类型注册已被删除,因为它们已由RFC 5988注册。o引言已缩短。o已删除“链接关系应用程序数据”注册表。o合并勘误表。o更新参考资料。o链接基数已澄清。o术语分别从“目标IRI”和“上下文IRI”更改为“链接目标”和“链接上下文”。o将URI分配给特定于序列化的已注册关系类型。o删除了链接头字段在语义上等同于HTML和Atom链接的误导性陈述。o更仔细地定义和使用“链接序列化”和“链接应用程序”。o澄清了目标属性的基数(一般和“类型”)。o更正了链接头字段的默认链接上下文,该上下文取决于表示的标识(根据RFC 7231)。o为链接头定义了建议的解析算法。o已指定目标属性的值空间及其定义。o ABNF已更新为与[RFC7230]兼容。特别是,空格现在是显式的。o HTTP标头字段上的某些参数现在可以显示为令牌。o HTTP头上的参数现在可以是无值的。o带引号字符串的处理现在由[RFC7230]定义。o现在需要引用“type”标题字段参数(因为“token”不允许“/”)。
Author's Address
作者地址
Mark Nottingham
马克诺丁汉
Email: mnot@mnot.net URI: https://www.mnot.net/
Email: mnot@mnot.net URI: https://www.mnot.net/