RFC 9264: Linkset: Media Types and a Link Relation Type for Link Sets
- E. Wilde,
- H. Van de Sompel
Abstract
This specification defines two formats and associated media types for representing sets of links as standalone documents. One format is based on JSON, and the other is aligned with the format for representing links in the HTTP "Link" header field. This specification also introduces a link relation type to support the discovery of sets of links.¶
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.¶
Information about the current status of this document, any
errata, and how to provide feedback on it may be obtained at
https://
Copyright Notice
Copyright (c) 2022 IETF Trust and the persons identified as the document authors. All rights reserved.¶
This document is subject to BCP 78 and the IETF Trust's Legal
Provisions Relating to IETF Documents
(https://
1. Introduction
Resources on the Web often use typed Web Links [RFC8288], either (1) embedded in resource representations -- for example, using the <link> element for HTML documents or (2) conveyed in the HTTP "Link" header field for documents of any media type. In some cases, however, providing links in this manner is impractical or impossible, and delivering a set of links as a standalone document is preferable.¶
Therefore, this specification defines two formats for representing sets of Web Links and their attributes as standalone documents. One serializes links in the same format as the format used in the HTTP "Link" header field, and the other serializes links in JSON. It also defines associated media types to represent sets of links, and the "linkset" relation type to support the discovery of any resource that conveys a set of links as a standalone document.¶
2. Terminology
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.¶
This specification uses the terms "link context" and "link target" in the same manner that "Web Linking" [RFC8288] uses them.¶
In the examples provided in this document, links in the HTTP "Link" header field are shown on separate lines in order to improve readability. Note, however, that as per Section 5.5 of "HTTP Semantics" [RFC9110], line breaks are deprecated in values for HTTP fields; only whitespaces and tabs are supported as separators.¶
3. Use Cases and Motivation
The following sections describe use cases in which providing links by means of a standalone document instead of in an HTTP "Link" header field or as links embedded in the resource representation is advantageous or necessary.¶
For all scenarios, links could be provided by means of a standalone document that is formatted according to the JSON-based serialization, the serialization aligned with the HTTP "Link" field format, or both. The former serialization is motivated by the widespread use of JSON and related tools, which suggests that handling sets of links expressed as JSON documents should be attractive to developers. The latter serialization is provided for compatibility with the existing serialization used in the HTTP "Link" field and to allow the reuse of tools created to handle it.¶
It is important to keep in mind that when providing links by means of a standalone representation, other links can still be provided using other approaches, i.e., it is possible to combine various mechanisms to convey links.¶
3.1. Third-Party Links
In some cases, it is useful that links pertaining to a resource are provided by a server other than the one that hosts the resource. For example, this allows:¶
In such cases, links pertaining to a resource can be provided by another, specific resource. That specific resource may be managed, by the same custodian or by another custodian, as the resource to which the links pertain. For clients intent on consuming links provided in that manner, it would be beneficial if the following conditions were met:¶
These requirements are addressed in this specification through the definition of two media types and a link relation type, respectively.¶
3.2. Challenges Writing to the HTTP "Link" Header Field
In some cases, it is not straightforward to write links to the HTTP "Link" header field from an application. This can, for example, be the case because not all required link information is available to the application or because the application does not have the capability to directly write HTTP fields. In such cases, providing links by means of a standalone document can be a solution. Making the resource that provides these links discoverable can be achieved by means of a typed link.¶
3.3. Large Number of Links
When conveying links in an HTTP "Link" header field, it is possible for the size of the HTTP response fields to become unpredictable. This can be the case when links are determined dynamically in a manner dependent on a range of contextual factors. It is possible to statically configure a web server to correctly handle large HTTP response fields by specifying an upper bound for their size. But when the number of links is unpredictable, estimating a reliable upper bound is challenging.¶
Section 15 of "HTTP Semantics" [RFC9110] defines error codes related to excess communication by the user agent ("413 Content Too Large" and "414 URI Too Long"), but no specific error codes are defined to indicate that response field content exceeds the upper bound that can be handled by the server and thus has been truncated. As a result, applications take countermeasures aimed at controlling the size of the HTTP "Link" header field -- for example, by limiting the links they provide to those with select relation types, thereby limiting the value of the HTTP "Link" header field to clients. Providing links by means of a standalone document overcomes challenges related to the unpredictable (to the web server implementation) nature of the size of HTTP "Link" header fields.¶
4. Document Formats for Sets of Links
This section specifies two document formats to convey a set of links. Both are based on the abstract model specified in Section 2 of "Web Linking" [RFC8288], which defines a link as consisting of a "link context", a "link relation type", a "link target", and optional "target attributes":¶
Links provided in the HTTP "Link" header field are intended to be used in the context of an HTTP interaction, and contextual information
that is available during an interaction is used to correctly interpret them.
Links provided in link sets, however, can be reused outside of an HTTP interaction, when no such contextual information is available.
As a result, implementers of link sets should strive to make them self-contained by adhering to the following recommendations
For links provided in the HTTP "Link" header field that have no anchor or that use relative references, the URI of the resource that delivers the links provides the contextual information that is needed for their correct interpretation. In order to support use cases where link set documents are reused outside the context of an HTTP interaction, it is RECOMMENDED to make them self-contained by adhering to the following guidelines:¶
If these recommendations are not followed, the interpretation of links in link set documents will depend on which URI is used as the context.¶
For a "title" attribute provided on a link in the HTTP "Link" header field, the language in which the title is expressed is provided by
the "Content
Note also that Section 3.3 of [RFC8288] deprecates the "rev" construct that was provided by [RFC5988] as a means to express links with a directionality that is the inverse of direct links that use the "rel" construct. In both serializations for link sets defined here, inverse links may be represented as direct links using the "rel" construct and by switching the roles of the resources involved in the link.¶
4.1. HTTP Link Document Format: application/linkset
This document format is nearly identical to the field value of the
HTTP "Link" header field as defined in
Section 3 of [RFC8288], more specifically by
its ABNF [RFC5234] production rule for "Link" and its subsequent rules. It differs from the format for field values of the
HTTP "Link" header field only in that not only spaces and horizontal tabs are allowed as separators but also newline
characters as a means to improve readability for humans.
The use of non-ASCII characters in the field value of the HTTP "Link" header field is not allowed
and as such is also not allowed in "application
The assigned media type for this format is "application
When converting an "application
Implementers of "application
It should be noted that the "application
4.2. JSON Document Format: application/linkset+json
This document format uses JSON [RFC8259] as the syntax to represent a set of links. The set of links follows the abstract model defined by Section 2 of [RFC8288].¶
The assigned media type for this format is "application
In the interests of interoperabilit
Implementers of "application
The "application
4.2.1. Set of Links
In the JSON representation of a set of links:¶
4.2.2. Link Context Object
In the JSON representation, one or more links that have the same link context are represented by a JSON object -- the link context object. A link context object adheres to the following rules:¶
4.2.3. Link Target Object
In the JSON representation, a link target is represented by a JSON object -- the link target object. A link target object adheres to the following rules:¶
The following example of a JSON-serialized set of links represents one link with its core components: link context, link relation type, and link target.¶
The following example of a JSON-serialized set of links represents two links that share a link context and relation type but have different link targets.¶
The following example shows a set of links that represents two links, each with a different link context, link target, and relation type. One relation type is registered, and the other is an extension relation type.¶
4.2.4. Link Target Attributes
A link may be further qualified by target attributes as defined by Section 2 of [RFC8288]. Three types of attributes exist:¶
The handling of these different types of attributes is described in the sections below.¶
4.2.4.1. Target Attributes Defined by Web Linking
Section 3.4.1 of [RFC8288] defines the following target attributes that may be used to annotate links: "hreflang", "media", "title", "title*", and "type"; these target attributes follow different occurrence and value patterns. In the JSON representation, these attributes MUST be conveyed as additional members of the link target object as follows:¶
- "hreflang":
- The "hreflang" target attribute, defined as optional and repeatable by [RFC8288], MUST be represented by an "hreflang" member, its value MUST be an array (even if there is only one value to be represented), and each value in that array MUST be a string -- representing one value of the "hreflang" target attribute for a link -- that follows the same model as the syntax discussed in [RFC8288].¶
- "media":
- The "media" target attribute, defined as optional and not repeatable by [RFC8288], MUST be represented by a "media" member in the link target object, and its value MUST be a string that follows the same model as the syntax discussed in [RFC8288].¶
- "title":
- The "title" target attribute, defined as optional and not repeatable by [RFC8288], MUST be represented by a "title" member in the link target object, and its value MUST be a JSON string.¶
- "title*":
- The "title*" target attribute, defined as optional and not repeatable by [RFC8288], is motivated by character encoding and language issues and follows the model defined in [RFC8187]. The details of the JSON representation that applies to "title*" are described in Section 4.2.4.2.¶
- "type":
- The "type" target attribute, defined as optional and not repeatable by [RFC8288], MUST be represented by a "type" member in the link target object, and its value MUST be a string that follows the same model as the syntax discussed in [RFC8288].¶
The following example illustrates how the "hreflang" (repeatable) target attribute and the "type" (not repeatable) target attribute are represented in a link target object.¶
4.2.4.2. Internationalized Target Attributes
In addition to the target attributes described in Section 4.2.4.1, Section 3.4 of [RFC8288] also supports attributes that follow the content model of [RFC8187]. In [RFC8288], these target attributes are recognizable by the use of a trailing asterisk in the attribute name, such as "title*". The content model of [RFC8187] uses a string-based microsyntax that represents the character encoding, an optional language tag, and the escaped attribute value encoded according to the specified character encoding.¶
The JSON serialization for these target attributes MUST be as follows:¶
The following example illustrates how the "title*" target attribute as defined by Section 3.4.1 of [RFC8288] is represented in a link target object.¶
The above example assumes that the German title contains an umlaut character (in the original syntax, it would be encoded as title*
4.2.4.3. Extension Target Attributes
Extension target attributes (e.g., as listed in Section 4.2.4.1) are attributes that are not defined by Section 3.4.1 of [RFC8288] but are nevertheless
used to qualify links.
They can be defined by communities in any way deemed necessary, and it is up to them
to make sure their usage is understood by target applications.
However, lacking standardization
The JSON serialization for these target attributes MUST be as follows:¶
The following example shows a link target object with three extension target attributes. The value for each extension target attribute is an array. The first two are regular extension target attributes, with the first one ("foo") having only one value and the second one ("bar") having two. The last extension target attribute ("baz*") follows the naming rule of [RFC8187] and therefore is encoded according to the serialization described in Section 4.2.4.2.¶
4.2.5. JSON Extensibility
The Web Linking model [RFC8288] provides for the use of extension target attributes as discussed in
Section 4.2.4.3.
The use of other forms of extensions is NOT RECOMMENDED.
Limiting the JSON format in this way allows unambiguous round trips between links provided in the HTTP "Link" header field,
sets of links serialized according to the "application
Cases may exist in which the use of extensions other than those discussed in Section 4.2.4.3 may be useful -- for example, when a link set publisher needs to include descriptive or technical metadata for internal consumption. If such extensions are used, they MUST NOT change the semantics of the JSON members defined in this specification. Agents that consume JSON linkset documents can safely ignore such extensions.¶
5. The "profile" Parameter for Media Types to Represent Sets of Links
As a means to convey specific constraints or conventions (as per [RFC6906]) that apply to a link set document,
the "profile" parameter MAY be used in conjunction with the media types "application
The value of the "profile" parameter MUST be a non-empty list of space-separated URIs, each of which identifies specific constraints or conventions that apply to the link set document. When providing multiple profile URIs, care should be taken that the corresponding profiles are not conflicting. Profile URIs MAY be registered in the IANA's "Profile URIs" registry in the manner specified by [RFC7284].¶
The presence of a "profile" parameter in conjunction with the "application
Section 7.4.2 shows an example of using the "profile" parameter in conjunction with the
"application
6. The "linkset" Relation Type for Linking to a Set of Links
The target of a link with the "linkset" relation type provides a set of links, including links in which the resource that is the link context participates.¶
A link with the "linkset" relation type MAY be provided in the header field and/or the body of a resource's representation. It may also be discovered by other means, such as through client-side information.¶
A resource MAY provide more than one link with a "linkset" relation type. Multiple such links can refer to the same set of links expressed using different media types, or to different sets of links, potentially provided by different third-party services.¶
The set of links provided by the resource that is the target of a "linkset" link may contain links in which the resource that is the context of the "linkset" link does not participate. User agents MUST process each link in the link set independently, including processing of the link context and link target, and MAY ignore links from the link set in which the context of the "linkset" link does not participate.¶
A user agent that follows a "linkset" link and obtains links for which anchors and targets are expressed as relative references (as per Section 4.1 of [RFC3986]) MUST determine what the context is for these links; it SHOULD ignore links for which it is unable to unambiguously make that determination.¶
As a means to convey specific constraints or conventions (as per [RFC6906]) that apply to a link set document, the "profile" attribute MAY be used in conjunction with the "linkset" link relation type. For example, the attribute could be used to indicate that a link set uses a specific, limited set of link relation types. The value of the "profile" attribute MUST be a non-empty list of space-separated URIs, each of which identifies specific constraints or conventions that apply to the link set document. Profile URIs MAY be registered in the IANA's "Profile URIs" registry in the manner specified by [RFC7284]. Section 7.4.1 shows an example of using the "profile" attribute on a link with the "linkset" relation type, making both the link set and the profile(s) to which it complies discoverable.¶
7. Examples
Sections 7.1 and 7.2
show examples whereby a set of links is provided as "application
7.1. Set of Links Provided as "application/linkset"
Figure 7 shows a client issuing an
HTTP GET request against resource <https://
Figure 8 shows the response to the GET request of
Figure 7. The response contains a "Content-Type" header field
specifying that the media type of the response is "application
7.2. Set of Links Provided as "application/linkset+json"
Figure 9 shows the client issuing an HTTP GET
request against <https://
Figure 10 shows the response to the HTTP GET request of Figure 9.
The set of links is serialized according to the media type "application
7.3. Discovering a Link Set via the "linkset" Link Relation Type
Figure 11 shows a client issuing an
HTTP HEAD request against resource
<https://
Figure 12 shows the response to the HEAD request of
Figure 11. The response contains an HTTP "Link" header field with
a link that has the "linkset" relation type. It indicates that a set of links is provided
by resource <https://
7.4. Link Set Profiles
The examples in this section illustrate the use of the "profile" attribute for a link with the "linkset" link relation type and the "profile" attribute for a link set media type. The examples are inspired by the implementation of link sets by GS1 (the standards body behind many of the world's barcodes).¶
7.4.1. Using a "profile" Attribute with a "linkset" Link
Figure 13 shows a client issuing an
HTTP HEAD request against trade item 09506000134352 at <https://
Figure 14 shows the server's response to the request of
Figure 13, including a "linkset" link with a "profile" attribute
that has the profile URI <https://
7.4.2. Using a "profile" Parameter with a Link Set Media Type
Figure 15 shows a client issuing an
HTTP HEAD request against the link set <https://
Figure 16 shows the server's response to the request of Figure 15. Note the "profile" parameter for the "application
7.4.3. Using a Link with a "profile" Link Relation Type
Note that the response shown in Figure 16 from the link set resource is equivalent to the response shown in Figure 17, which leverages the "profile" link relation type defined in [RFC6906].¶
A link with a "profile" link relation type as shown in Figure 17 can also be conveyed in the link set document itself. This is illustrated by Figure 18. Following the recommendation that all links in a link set document should have an explicit anchor, such a link has the URI of the link set itself as the anchor and the profile URI as the target. Multiple profile URIs are handled by using multiple "href" members.¶
8. IANA Considerations
8.1. Link Relation Type: linkset
The link relation type below has been registered by IANA in the "Link Relation Types" registry as per Section 4.2 of [RFC8288]:¶
8.2. Media Type: application/linkset
The Internet media type "application
- Type name:
- application¶
- Subtype name:
- linkset¶
- Required parameters:
- N/A¶
- Optional parameters:
- profile¶
- Encoding considerations:
- Linksets are encoded according to the definitions provided in [RFC8288]. The encoding discussed in [RFC8288] is based on the general encoding rules specified by HTTP [RFC9110] and allows specific parameters to be extended by the indication of character encoding and language as defined by [RFC8187].¶
- Security considerations:
- The security considerations of RFC 9264 apply.¶
- Interoperability considerations:
- N/A¶
- Published specification:
- RFC 9264¶
- Applications that use this media type:
- This media type is not specific to any application, as it can be used by any application that wants to interchange Web Links.¶
- Additional information:
8.3. Media Type: application/linkset+json
The Internet media type "application
- Type name:
- application¶
- Subtype name:
- linkset+json¶
- Required parameters:
- N/A¶
- Optional parameters:
- profile¶
- Encoding considerations:
- The encoding considerations of [RFC8259] apply.¶
- Security considerations:
- The security considerations of RFC 9264 apply.¶
- Interoperability considerations:
- The interoperabilit
y considerations of [RFC8259] apply.¶ - Published specification:
- RFC 9264¶
- Applications that use this media type:
- This media type is not specific to any application, as it can be used by any application that wants to interchange Web Links.¶
- Additional information:
9. Security Considerations
The security considerations of Section 7 of [RFC3986] apply, as well as those of Web Linking [RFC8288] as long as the latter are not specifically discussing the risks of exposing information in HTTP header fields.¶
In general, links may cause information leakage when they expose information (such as URIs) that can be sensitive or private. Links may expose "hidden URIs" that are not supposed to be openly shared and that may not be sufficiently protected. Ideally, none of the URIs exposed in links should be supposed to be "hidden"; instead, if these URIs are supposed to be limited to certain users, then technical measures should be put in place so that accidentally exposing them does not cause any harm.¶
For the specific mechanisms defined in this specification, two security considerations should be taken into account:¶
10. References
10.1. Normative References
- [RFC2119]
-
Bradner, S., "Key words for use in RFCs to Indicate Requirement Levels", BCP 14, RFC 2119, DOI 10
.17487 , , <https:///RFC2119 www >..rfc -editor .org /info /rfc2119 - [RFC3986]
-
Berners-Lee, T., Fielding, R., and L. Masinter, "Uniform Resource Identifier (URI): Generic Syntax", STD 66, RFC 3986, DOI 10
.17487 , , <https:///RFC3986 www >..rfc -editor .org /info /rfc3986 - [RFC5234]
-
Crocker, D., Ed. and P. Overell, "Augmented BNF for Syntax Specifications: ABNF", STD 68, RFC 5234, DOI 10
.17487 , , <https:///RFC5234 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 , , <https:///RFC5646 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 , , <https:///RFC6838 www >..rfc -editor .org /info /rfc6838 - [RFC8174]
-
Leiba, B., "Ambiguity of Uppercase vs Lowercase in RFC 2119 Key Words", BCP 14, RFC 8174, DOI 10
.17487 , , <https:///RFC8174 www >..rfc -editor .org /info /rfc8174 - [RFC8187]
-
Reschke, J., "Indicating Character Encoding and Language for HTTP Header Field Parameters", RFC 8187, DOI 10
.17487 , , <https:///RFC8187 www >..rfc -editor .org /info /rfc8187 - [RFC8259]
-
Bray, T., Ed., "The JavaScript Object Notation (JSON) Data Interchange Format", STD 90, RFC 8259, DOI 10
.17487 , , <https:///RFC8259 www >..rfc -editor .org /info /rfc8259 - [RFC8288]
-
Nottingham, M., "Web Linking", RFC 8288, DOI 10
.17487 , , <https:///RFC8288 www >..rfc -editor .org /info /rfc8288 - [RFC9110]
-
Fielding, R., Ed., Nottingham, M., Ed., and J. Reschke, Ed., "HTTP Semantics", STD 97, RFC 9110, DOI 10
.17487 , , <https:///RFC9110 www >..rfc -editor .org /info /rfc9110 - [W3C
.REC -json -ld] -
Sporny, M., Ed., Kellogg, G., Ed., and M. Lanthaler, Ed., "JSON-LD 1.1: A JSON-based Serialization for Linked Data", W3C Recommendation REC
-json , , <https://-ld -20140116 www >..w3 .org /TR /json -ld /
10.2. Informative References
- [DCMI-TERMS]
-
Dublin Core Metadata Initiative, "DCMI Metadata Terms", , <https://
www >..dublincore .org /specifications /dublin -core /dcmi -terms / - [RFC5988]
-
Nottingham, M., "Web Linking", RFC 5988, DOI 10
.17487 , , <https:///RFC5988 www >..rfc -editor .org /info /rfc5988 - [RFC6690]
-
Shelby, Z., "Constrained RESTful Environments (CoRE) Link Format", RFC 6690, DOI 10
.17487 , , <https:///RFC6690 www >..rfc -editor .org /info /rfc6690 - [RFC6906]
-
Wilde, E., "The 'profile' Link Relation Type", RFC 6906, DOI 10
.17487 , , <https:///RFC6906 www >..rfc -editor .org /info /rfc6906 - [RFC7284]
-
Lanthaler, M., "The Profile URI Registry", RFC 7284, DOI 10
.17487 , , <https:///RFC7284 www >..rfc -editor .org /info /rfc7284 - [W3C
.REC -rdf11 -concepts] -
Cyganiak, R., Ed., Wood, D., Ed., and M. Lanthaler, Ed., "RDF 1.1 Concepts and Abstract Syntax", W3C Consortium Recommendation REC
-rdf11 , , <https://-concepts www >..w3 .org /TR /rdf11 -concepts /
Appendix A. JSON-LD Context
A set of links rendered according to the
JSON serialization defined in Section 4.2 can be interpreted
as RDF triples by adding a JSON-LD context [W3C.REC-json-ld] that maps
the JSON keys to corresponding Linked Data terms. And, as per
Section 6.1 of [W3C.REC-json-ld],
when delivering a link set that is rendered according to the "application
Figure 19 shows the response to an HTTP GET against the URI of a link set resource and
illustrates this approach to support the discovery of a JSON-LD context. This example is inspired by the GS1 implementation and
shows a link set that uses relation types from the GS1 vocabulary at <https://
In order to obtain the JSON-LD context conveyed by the server, the user agent issues an HTTP GET against the
link target of the link with the "http://
Applying the JSON-LD context of Figure 20 to the link set of Figure 19
allows transforming the "application
Acknowledgements
Thanks for comments and suggestions provided by Phil Archer, Dominique Guinard, Mark Nottingham, Julian Reschke, Rob Sanderson, Stian Soiland-Reyes, Sarven Capadisli, and Addison Phillips.¶