Internet-Draft Accept-Any-Of option for CoAP December 2026
Amsüss Expires 5 June 2027 [Page]
Workgroup:
CoRE
Internet-Draft:
draft-amsuess-core-accept-any-02
Updates:
7641 (if approved)
Published:
Intended Status:
Standards Track
Expires:
Author:
C. Amsüss

Accept-Any-Of option for CoAP

Abstract

This memo defines the Accept-Any-Of option, which provides a more flexible content negotiation than the one originally specified for the Constrained Application Protocol (CoAP) in [RFC7252]. As this is particularly useful with, but ruled out in, CoAP observation ([RFC7641]), that is updated to allow it.

About This Document

This note is to be removed before publishing as an RFC.

Status information for this document may be found at https://datatracker.ietf.org/doc/draft-amsuess-core-accept-any/.

Discussion of this document takes place on the Constrained RESTful Environments Working Group mailing list (mailto:core@ietf.org), which is archived at https://mailarchive.ietf.org/arch/browse/core/. Subscribe at https://www.ietf.org/mailman/listinfo/core/.

Source for this draft and an issue tracker can be found at https://github.com/chrysn/accept-any.

Status of This Memo

This Internet-Draft is submitted in full conformance with the provisions of BCP 78 and BCP 79.

Internet-Drafts are working documents of the Internet Engineering Task Force (IETF). Note that other groups may also distribute working documents as Internet-Drafts. The list of current Internet-Drafts is at https://datatracker.ietf.org/drafts/current/.

Internet-Drafts are draft documents valid for a maximum of six months and may be updated, replaced, or obsoleted by other documents at any time. It is inappropriate to use Internet-Drafts as reference material or to cite them other than as "work in progress."

This Internet-Draft will expire on 5 June 2027.

▲

Table of Contents

1. Introduction

[ This document has been revised from the original 2019 version after pub-sub moved away from desiring non-created states, and moved back to that during AD review in 2026. ]

When CoAP Content-Format was defined in [RFC7252], the choice was made to have the initial content negotiation allow the client to only pick zero or one content format (Accept). This is a good choice for many situations and ensures that proxies can cache as much as possible without added complexity. A client that does not know a usable content format would either leave the request field absent, indicating it would accept any response, or try several acceptable values in a series of requests.

In line with that choice, observation ([RFC7641]) requires notification responses to carry the same Content-Format in the notification as in the original response.

For applications that expect a representation to change its media type during an observation's lifetime, [RFC8710] introduced a way of wrapping response payloads in an application/multipart-core media type. That approach is convenient for bags of representations, but lacks actual content negotiation and produces representations that are not directly usable but need to be processed from inside the multipart representation.

This document introduces an additional way for the client to indicate its set of acceptable content-formats, and removes the same-content-format limitation during observation.

1.1. Conventions

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.

2. The Accept-Any-Of Option

A new option Accept-Any-Of is defined. It is critical [ I don't fully see why but follow Accept here ], safe-to-forward and part of the cache key. Its format is uint, up to 2 bytes long (indicating a content format), it is Class E in OSCORE, usable in requests only, and repeatable.

Table 1: Accept-Any-Of; C=Critical, U=Unsafe, N=NoCacheKey, R=Repeatable
No. C U N R Name Format Length Default
TBD1 x     x Accept-Any-Of uint 0-2 (none)

Repeatability is the only aspect in which it differs from Accept in terms of option properties.

The values in a sequence of Accept-Any-Of options indicate a list of acceptable representations in order of decreasing preference. A server MUST answer with the first format it can represent the requested state in, or 4.06 (Not Acceptable) if it could answer successfully but the response would not match any of the option values.

The Accept-Any-Of option MUST NOT be used exactly once; that request's meaning would be identical to that of a single Accept option. Instead, a single Accept option is used.

The Accept-Any-Of option MUST NOT be used alongside an Accept option.

2.1. Proxy behavior

A proxy MAY ignore this option per its properties (and serve a cached response if the cache key matches), but can implement additional behavior to enhance its cache.

A proxy is allowed to serve a cached representation to a request with a different sequence of Accept-Any-Of options, provided the second request has an Accept value that matches the cached representation, or all the content formats that precede the available content format in the second request's Accept-Any-Of options also preceded the available representation in any earlier (fresh) request's list.

When a request that carries Accept-Any-Of is answered 4.06 (or with any but the first format requested by Accept-Any-Of in its Content-Format), a proxy SHOULD [ we can't have a MUST here w/o making it non-safe-to-forward, but I think it's sufficient ] invalidate all known representations in any of the requested formats (or the formats preceding the returned one, respectively).

3. Update to RFC7641

3.1. Changed behavior

The requirement that subsequent notifications carry the same Content-Format option as the original response (Section 3.2 of [RFC7641]) is lifted. Note that the requirement resulting from an Accept option in the request (that has the same effect of not admitting changes to the Content-Format) is unchanged.

3.2. Rationale

Observing resources whose available representations changed is a key feature of Accept-Any-Of, and necessary to implement pub-sub topics that have no initial value (but a "null" representation with a dedicated content format) without losing content negotiation and direct usability of the response.

The requirement was introduced initially before such content negotiation was thought of, and is not a necessary part to the remainder of the observation document.

As long as the limitation is in place, the origin server has no clear action guidance when its resource changes the available content formats (see below).

3.3. Impact

Changes to the returned media type can either happen when

  • Accept-Any-Of was sent in the request -- in which case both server and client know the updated rules, or

  • no Accept header was sent -- in which case the server whose representation changes to require a new content format has no clear way of indicating that under [RFC7641] (ending with 4.06 Not Acceptable would be close but isn't the expected response to a repeated request); if the server changes the content format in a notification to an unaware client, the client would catch it as a bad response (probably similar to a response with a Content-Format not matching the sent Accept). The client might regard the observation as being aborted while the server does not, and will terminate the observation with a RST on the next notification (or close the connection in TCP).

    Applications are still free to require constant content formats; clients would treat what could previously be treated as a protocol error would now treat it as an application error.

Impact on proxies: A proxy that enforces the previous rule on Content-Format staying constant would close observations (probably with something like 5.02 Bad Gateway), and the client would need to re-establish. No proxy implementations are known that implement that behavior.

4. IANA Considerations

IANA is not yet requested to register Table 1 in [IANA.core-parameters].

5. Security Considerations

TBD

6. References

6.1. Normative References

[IANA.core-parameters]
IANA, "Constrained RESTful Environments (CoRE) Parameters", <https://www.iana.org/assignments/core-parameters>.
[IANA.media-types]
IANA, "Media Types", <https://www.iana.org/assignments/media-types>.
[RFC2119]
Bradner, S., "Key words for use in RFCs to Indicate Requirement Levels", BCP 14, RFC 2119, DOI 10.17487/RFC2119, , <https://www.rfc-editor.org/rfc/rfc2119>.
[RFC7252]
Shelby, Z., Hartke, K., and C. Bormann, "The Constrained Application Protocol (CoAP)", RFC 7252, DOI 10.17487/RFC7252, , <https://www.rfc-editor.org/rfc/rfc7252>.
[RFC7641]
Hartke, K., "Observing Resources in the Constrained Application Protocol (CoAP)", RFC 7641, DOI 10.17487/RFC7641, , <https://www.rfc-editor.org/rfc/rfc7641>.
[RFC8174]
Leiba, B., "Ambiguity of Uppercase vs Lowercase in RFC 2119 Key Words", BCP 14, RFC 8174, DOI 10.17487/RFC8174, , <https://www.rfc-editor.org/rfc/rfc8174>.

6.2. Informative References

[I-D.ietf-core-coap-pubsub]
Jimenez, J., Koster, M., and A. Keränen, "A publish-subscribe architecture for the Constrained Application Protocol (CoAP)", Work in Progress, Internet-Draft, draft-ietf-core-coap-pubsub-22, , <https://datatracker.ietf.org/doc/html/draft-ietf-core-coap-pubsub-22>.
[I-D.jimenez-core-coap-no-content-00]
Jimenez, J. and C. Bormann, "The 2.06 (No Content) Response Code for the Constrained Application Protocol (CoAP)", Work in Progress, Internet-Draft, draft-jimenez-core-coap-no-content-00, , <https://datatracker.ietf.org/doc/html/draft-jimenez-core-coap-no-content-00>.
[RFC8710]
Fossati, T., Hartke, K., and C. Bormann, "Multipart Content-Format for the Constrained Application Protocol (CoAP)", RFC 8710, DOI 10.17487/RFC8710, , <https://www.rfc-editor.org/rfc/rfc8710>.

Appendix A. Open questions

Appendix B. Comparison with 2.06 No Content

This document was revived with minimal modifications (mostly the addition of this appendix) as a response to [I-D.jimenez-core-coap-no-content-00].

To serve the same purpose as that document for the current [I-D.ietf-core-coap-pubsub]:

It is the author's impression that this document's approach can solve the same issue as no-content, but with less impact on the REST model underlying CoAP (in that "exists but has no value" does not become a new state). More convenient aspects of this approach are that a null media type can easily be PUT into a resource (as opposed to introducing a variant of DELETE that just affects the content but not the resource as a whole), and that it opens for additional states that can be represented in new media types (e.g. a generic "tombstone" type that can be placed in a resource to indicate that there is no fresh representation, but possibly tells a bit about the history).

B.1. Media type for empty resources

[ This text might be moved into [I-D.ietf-core-coap-pubsub] if adopted there. ]

This document specifies a new media type and content-format that can be used in places where a resource is empty in the sense of not having a representation in any other concrete format.

It is encoded in an empty byte sequence.

Semantically, it is equivalent to a multi-part alternative representation with no actual entries, such as the empty CBOR array encoded in application/multipart-core as defiend in [RFC8710]. Apart from the single-byte saving, having a dedicated media type allows clients to specifically only allow this minimal format in a response, as opposed to being open any media type encoded in a non-empty multipart message.

For registration into [IANA.media-types], it is described as:

  • Type name: application

  • Subtype name: multipart-empty

  • Required parameters: N/A

  • Optional parameters: N/A

  • Encoding considerations: This media type only describes empty representations.

  • Applications that use this media type: [I-D.ietf-core-coap-pubsub] (if applied)

  • Intended usage: limited use -- in applications where the absence of content in a resource is distinct from the resource not existing at all.

In parallel, the content-format CPA26 is described for inclusion into [IANA.core-parameters] with those properties:

  • Content Type: application/multipart-empty

  • Content Coding: (none / identity)

  • Media type: application/multipart-empty

  • ID: CPA26 [ RFC editor is requested to replacre all occurrences of that value with the value assigned by IANA ]

  • Reference: [ this document ]

Author's Address

Christian Amsüss
Austria