MASQUE                                                       D. Schinazi
Internet-Draft                                                Google LLC
Intended status: Standards Track                               L. Pardue
Expires: 13 January 10 April 2022                                        Cloudflare
                                                            12 July
                                                          7 October 2021

                       Using Datagrams with HTTP
                    draft-ietf-masque-h3-datagram-03
                    draft-ietf-masque-h3-datagram-04

Abstract

   The QUIC DATAGRAM extension provides application protocols running
   over QUIC with a mechanism to send unreliable data while leveraging
   the security and congestion-control properties of QUIC.  However,
   QUIC DATAGRAM frames do not provide a means to demultiplex
   application contexts.  This document describes how to use QUIC
   DATAGRAM frames when the application protocol running over QUIC is
   HTTP/3.  It associates datagrams with client-initiated bidirectional
   streams and defines an optional additional demultiplexing layer.
   Additionally, this document defines how to convey datagrams over
   prior versions of HTTP.

Discussion Venues

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

   Discussion of this document takes place on the MASQUE WG mailing list
   (masque@ietf.org), which is archived at
   https://mailarchive.ietf.org/arch/browse/masque/.

   Source for this draft and an issue tracker can be found at
   https://github.com/ietf-wg-masque/draft-ietf-masque-h3-datagram.

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 13 January 10 April 2022.

Copyright Notice

   Copyright (c) 2021 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://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.

Table of Contents

   1.  Introduction  . . . . . . . . . . . . . . . . . . . . . . . .   3
     1.1.  Conventions and Definitions . . . . . . . . . . . . . . .   3   4
   2.  Multiplexing  . . . . . . . . . . . . . . . . . . . . . . . .   3   4
     2.1.  Datagram Contexts . . . . . . . . . . . . . . . . . . . .   4
     2.2.  Datagram Formats  . . . . . . . . . . . . . . . . . . . .   5
     2.3.  Context ID Allocation . . . . . . . . . . . . . . . . . .   4   5
   3.  HTTP/3 DATAGRAM Format  . . . . . . . . . . . . . . . . . . .   4   6
   4.  CAPSULE HTTP/3 Frame Definition  Capsules  . . . . . . . . . . . . . . .   6 . . . . . . . . . . .   7
     4.1.  The REGISTER_DATAGRAM_CONTEXT  Capsule Protocol  . . . . . . . . . .   7 . . . . . . . . . .   8
     4.2.  The REGISTER_DATAGRAM_NO_CONTEXT Capsule  Requirements  . . . . . . . . . . . . . . . . . . . . . .   9
     4.3.  The CLOSE_DATAGRAM_CONTEXT Capsule  Intermediary Processing . . . . . . . . . . .  10 . . . . . .   9
     4.4.  The DATAGRAM  Capsule Types . . . . . . . . . . . . . . . . . .  11
   5.  Context Extensibility . . . .  10
       4.4.1.  The REGISTER_DATAGRAM_CONTEXT Capsule . . . . . . . .  10
       4.4.2.  The REGISTER_DATAGRAM_NO_CONTEXT Capsule  . . . . . .  11
       4.4.3.  The CLOSE_DATAGRAM_CONTEXT Capsule  . .  12
     5.1.  The CLOSE_CODE Context Extension Type . . . . . . .  12
       4.4.4.  The DATAGRAM Capsule  . . .  13
     5.2.  The DETAILS Context Extension Type . . . . . . . . . . .  13
   6. . .  14
   5.  The H3_DATAGRAM HTTP/3 SETTINGS Parameter . . . . . . . . . .  13
   7.  Prioritization  .  16
     5.1.  Note About Draft Versions . . . . . . . . . . . . . . . .  16
   6.  Prioritization  . . . . . .  14
   8.  HTTP/1.x and HTTP/2 Support . . . . . . . . . . . . . . . . .  14
   9.  16
   7.  Security Considerations . . . . . . . . . . . . . . . . . . .  14
   10.  17
   8.  IANA Considerations . . . . . . . . . . . . . . . . . . . . .  14
     10.1.  17
     8.1.  HTTP/3 CAPSULE Frame SETTINGS Parameter . . . . . . . . . . . . . . . .  17
     8.2.  Capsule Types . . .  14
     10.2.  HTTP/3 SETTINGS Parameter . . . . . . . . . . . . . . .  15
     10.3.  Capsule Types . . . .  17
     8.3.  Datagram Format Types . . . . . . . . . . . . . . . . . .  15
     10.4.  18
     8.4.  Context Extension Types Close Codes . . . . . . . . . . . . . . . .  16
     10.5.  Context Close Codes . . .  19
   9.  References  . . . . . . . . . . . . . . .  17
   11. . . . . . . . . . .  19
     9.1.  Normative References  . . . . . . . . . . . . . . . . . .  19
     9.2.  Informative References  . . .  17 . . . . . . . . . . . . . .  20
   Appendix A.  Examples . . . . . . . . . . . . . . . . . . . . . .  18  21
     A.1.  CONNECT-UDP . . . . . . . . . . . . . . . . . . . . . . .  18  21
     A.2.  CONNECT-UDP with Timestamp Extension  . . . . . . . . . .  19  21
     A.3.  CONNECT-IP with IP compression  . . . . . . . . . . . . .  20  22
     A.4.  WebTransport  . . . . . . . . . . . . . . . . . . . . . .  21  24
   Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . . .  22  24
   Authors' Addresses  . . . . . . . . . . . . . . . . . . . . . . .  22  24

1.  Introduction

   The QUIC DATAGRAM extension [DGRAM] provides application protocols
   running over QUIC [QUIC] with a mechanism to send unreliable data
   while leveraging the security and congestion-control properties of
   QUIC.  However, QUIC DATAGRAM frames do not provide a means to
   demultiplex application contexts.  This document describes how to use
   QUIC DATAGRAM frames when the application protocol running over QUIC
   is HTTP/3 [H3].  It associates datagrams with client-initiated
   bidirectional streams and defines an optional additional
   demultiplexing layer.  Additionally, this document defines how to
   convey datagrams over prior versions of HTTP.

1.1.  Conventions and Definitions

   The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
   "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and
   "OPTIONAL" in this

   This document are to be interpreted is structured as described in BCP
   14 follows:

   *  Section 2 presents core concepts for multiplexing across HTTP
      versions.

      -  Section 2.1 defines datagram contexts, an optional end-to-end
         multiplexing concept scoped to each HTTP request.

      -  Section 2.2 defines datagram formats, which are scoped to
         contexts.  Formats communicate the format and encoding of
         datagrams sent using the associated context.

      -  Contexts are identified using a variable-length integer.
         Requirements for allocating identifier values are detailed in
         Section 2.3.

   *  Section 3 defines how QUIC DATAGRAM frames are used with HTTP/3.
      Section 5 defines an HTTP/3 setting that endpoints can use to
      advertise support of the frame.

   *  Section 4 introduces the Capsule Protocol and the "data stream"
      concept.  Data streams are initiated using special-purpose HTTP
      requests, after which Capsules, an end-to-end message, can be
      sent.

      -  The following Capsule types are defined, together with guidance
         for defining new types:

         o  REGISTER_DATAGRAM_CONTEXT Section 4.4.1
         o  REGISTER_DATAGRAM_NO_CONTEXT Section 4.4.2

         o  CLOSE_DATAGRAM_CONTEXT Section 4.4.3

         o  DATAGRAM Section 4.4.4

1.1.  Conventions and Definitions

   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.  Multiplexing

   When running over HTTP/3, multiple exchanges of datagrams need the
   ability to coexist on a given QUIC connection.  To allow this, HTTP
   datagrams contain two layers of multiplexing.  First, the QUIC
   DATAGRAM frame payload starts with an encoded stream identifier that
   associates the datagram with a given QUIC stream.  Second, datagrams
   optionally carry a context identifier (see Section 2.1) that allows
   multiplexing multiple datagram contexts related to a given HTTP
   request.  Conceptually, the first layer of multiplexing is per-hop,
   while the second is end-to-end.

   When running over HTTP/2, the first level of demultiplexing is
   provided by the HTTP/2 framing layer.  When running over HTTP/1,
   requests are strictly serialized in the connection, therefore the
   first layer of demultiplexing is not needed.

2.1.  Datagram Contexts

   Within the scope of a given HTTP request, contexts provide an
   additional demultiplexing layer.  Contexts determine the encoding of
   datagrams, and can be used to implicitly convey metadata.  For
   example, contexts can be used for compression to elide some parts of
   the datagram: the context identifier then maps to a compression
   context that the receiver can use to reconstruct the elided data.

   Contexts are optional, their whether to use them or not is negotiated decided by the
   client on each request stream using registration capsules, see
   Section 4.1 4.4.1 and Section 4.2. 4.4.2.  When contexts are used, they are
   identified within the scope of a given request by a numeric value,
   referred to as the context ID.  A context ID is a 62-bit integer (0
   to 2^62-1).

   While stream IDs are a per-hop concept, context IDs are an end-to-end
   concept.  In other words, if a datagram travels through one or more
   intermediaries on its way from client to server, the stream ID will
   most likely change from hop to hop, but the context ID will remain
   the same.  Context IDs are opaque to intermediaries.

2.2.  Context ID Allocation

   Implementations of HTTP Datagrams MUST provide a context ID
   allocation service.  That service will allow applications co-located
   with HTTP to request  Datagram Formats

   When an endpoint registers a unique datagram context ID that they can subsequently
   use for their own purposes.  The HTTP implementation will then parse (or the context ID lack of incoming HTTP Datagrams and use
   contexts), it to deliver communicates the
   frame to format (i.e., the appropriate application semantics and
   encoding) of datagrams sent using this context.

   Even-numbered context IDs are client-initiated, while odd-numbered
   context IDs are server-initiated.  This means that an HTTP client
   implementation is
   acccomplished by sending a Datagram Format Type as part of the context ID allocation
   registration capsule, see Section 4.4.1 and Section 4.4.2.  This type
   identifier is registered with IANA (see Section 8.3) and allows
   applications that use HTTP Datagrams to indicate what the content of
   datagrams are.  Registration capsules carry a Datagram Format
   Additional Data field which allows sending some additional
   information that would impact the format of datagrams.

   For example, a protocol which proxies IP packets can define a
   Datagram Format Type which represents an IP packet.  The
   corresponding Datagram Format Additional Data field would be empty.
   An extension to such a protocol that wishes to compress IP addresses
   could define a distinct Datagram Format Type and exchange two IP
   addresses via the Datagram Format Additional Data field.  Then any
   datagrams with that type would contain the IP packet with addresses
   elided.

2.3.  Context ID Allocation

   Implementations of HTTP Datagrams MUST provide a context ID
   allocation service.  That service will allow applications co-located
   with HTTP to request a unique context ID that they can subsequently
   use for their own purposes.  The HTTP implementation will then parse
   the context ID of incoming HTTP Datagrams and use it to deliver the
   frame to the appropriate application context.

   Even-numbered context IDs are client-initiated, while odd-numbered
   context IDs are server-initiated.  This means that an HTTP client
   implementation of the context ID allocation service MUST only provide
   even-numbered IDs, while a server implementation MUST only provide
   odd-numbered IDs.  Note that, once allocated, any context ID can be
   used by both client and server - only allocation carries separate
   namespaces to avoid requiring synchronization.  Additionally, note
   that the context ID namespace is tied to a given HTTP request: it is
   possible for the same numeral context ID to be used simultaneously in
   distinct requests.

3.  HTTP/3 DATAGRAM Format

   When used with HTTP/3, the Datagram Data field of QUIC DATAGRAM
   frames uses the following format (using the notation from the
   "Notational Conventions" section of [QUIC]):

   HTTP/3 Datagram {
     Quarter Stream ID (i),
     [Context ID (i)],
     HTTP Datagram Payload (..),
   }

                      Figure 1: HTTP/3 DATAGRAM Format

   Quarter Stream ID:  A variable-length integer that contains the value
      of the client-initiated bidirectional stream that this datagram is
      associated with, divided by four.  (The four (the division by four stems from
      the fact that HTTP requests are sent on client-initiated
      bidirectional streams, and those have stream IDs that are
      divisible by four.) four).  The largest legal QUIC stream ID value is
      2^62-1, so the largest legal value of Quarter Stream ID is 2^62-1
      / 4.  Receipt of a frame that includes a larger value MUST be
      treated as a connection error of type FRAME_ENCODING_ERROR.

   Context ID:  A variable-length integer indicating the context ID of
      the datagram (see Section 2.1).  Whether or not this field is
      present depends on which registration capsules were exchanged on
      the associated stream: if a REGISTER_DATAGRAM_CONTEXT capsule (see
      Section 4.1) 4.4.1) has been sent or received on this stream, then the
      field is present; if a REGISTER_DATAGRAM_NO_CONTEXT capsule (see
      Section 4.2) 4.4.2) has been sent or received, then this field is
      absent; if neither has been sent or received, then it is not yet
      possible to parse this datagram and the receiver MUST either drop
      that datagram silently or buffer it temporarily while awaiting the
      registration capsule.

   HTTP Datagram Payload:  The payload of the datagram, whose semantics
      are defined by individual applications.  Note that this field can
      be empty.

   Intermediaries parse the Quarter Stream ID field in order to
   associate the QUIC DATAGRAM frame with a stream.  If an intermediary
   receives a QUIC DATAGRAM frame whose payload is too short to allow
   parsing the Quarter Stream ID field, the intermediary MUST treat it
   as an HTTP/3 connection error of type H3_GENERAL_PROTOCOL_ERROR.  The
   Context ID field is optional and its use whether it is present or not is negotiated end-to-end,
   decided end-to-end by the client, see Section 4.2. 4.4.2.  Therefore
   intermediaries cannot know whether the Context ID field is present or
   absent and they MUST ignore any HTTP/3 Datagram fields after the
   Quarter Stream ID.

   Endpoints parse both the Quarter Stream ID field and the Context ID
   field in order to associate the QUIC DATAGRAM frame with a stream and
   context within that stream.  If an endpoint receives a QUIC DATAGRAM
   frame whose payload is too short to allow parsing the Quarter Stream
   ID field, the endpoint MUST treat it as an HTTP/3 connection error of
   type H3_GENERAL_PROTOCOL_ERROR.  If an endpoint receives a QUIC
   DATAGRAM frame whose payload is long enough to allow parsing the
   Quarter Stream ID field but too short to allow parsing the Context ID
   field, the endpoint MUST abruptly terminate the corresponding stream
   with a stream error of type H3_GENERAL_PROTOCOL_ERROR.

   Endpoints MUST NOT send HTTP/3 datagrams unless the corresponding
   stream's send side is open.  On a given endpoint, once the receive
   side of a stream is closed, incoming datagrams for this stream are no
   longer expected so the endpoint can release related state.  Endpoints
   MAY keep state for a short time to account for reordering.  Once the
   state is released, the endpoint MUST silently drop received
   associated datagrams.

   If an HTTP/3 datagram is received and its Quarter Stream ID maps to a
   stream that has not yet been created, the receiver SHALL either drop
   that datagram silently or buffer it temporarily while awaiting the
   creation of the corresponding stream.

4.  CAPSULE HTTP/3 Frame Definition

   CAPSULE  Capsules

   This specification introduces the Capsule Protocol.  The Capsule
   Protocol is a sequence of type-length-value tuples that allows
   endpoints to reliably sending communicate request-related information end-to-
   end, even in the presence of HTTP intermediaries.

   CAPSULE is

4.1.  Capsule Protocol

   This specification defines the "data stream" of an HTTP/3 Frame (as opposed to HTTP request as
   the bidirectional stream of bytes that follow the headers in both
   directions.  In HTTP/1.x, the data stream consists of all bytes on
   the connection that follow the blank line that concludes either the
   request header section, or the 2xx (Successful) response header
   section.  In HTTP/2 and HTTP/3, the data stream of a QUIC frame) which SHALL
   only be given HTTP
   request consists of all bytes sent in client-initiated bidirectional streams.
   Intermediaries forward received CAPSULE DATA frames on with the same
   corresponding stream ID.  The concept of a data stream is
   particularly relevant for methods such as CONNECT where it would forward DATA frames.  Each Capsule Type determines
   whether it there is opaque or transparent to intermediaries: opaque
   capsules are forwarded unmodified while transparent ones can be
   parsed, added, no
   HTTP message content after the headers.

   Definitions of new HTTP Methods or removed by intermediaries.

   This specification of CAPSULE currently new HTTP Upgrade Tokens can
   state that their data stream uses HTTP/3 frame type
   0xffcab5. the Capsule Protocol.  If this document is approved, a lower number will be
   requested they do
   so, that means that the contents of their data stream uses the
   following format (using the notation from IANA.

   CAPSULE HTTP/3 Frame the "Notational
   Conventions" section of [QUIC]):

   Capsule Protocol {
     Capsule (..) ...,
   }

                  Figure 2: Capsule Protocol Stream Format

   Capsule {
     Capsule Type (i) = 0xffcab5,
     Length (i),
     Capsule Type Length (i),
     Capsule Data Value (..),
   }

                          Figure 2: CAPSULE HTTP/3 Frame 3: Capsule Format

   The Type and Length fields follows the definition of HTTP/3 frames
   from [H3].  The payload consists of:

   Capsule Type:  The type  A variable-length integer indicating the Type of this the
      capsule.  Endpoints that receive a capsule with an unknown Capsule Data:  Data whose semantics depends on
      Type MUST silently skip over that capsule.

   Capsule Length:  The length of the Capsule Type.

   Unless otherwise specified, all Value field following this
      field, encoded as a variable-length integer.  Note that this field
      can have a value of zero.

   Capsule Value:  The payload of this capsule.  Its semantics are
      determined by the value of the Capsule Type field.

4.2.  Requirements

   If the definition of an HTTP Method or HTTP Upgrade Token states that
   it uses the capsule protocol, its implementations MUST follow the
   following requirements:

   *  A server MUST NOT send any Transfer-Encoding or Content-Length
      header fields in a 2xx (Successful) response.  If a client
      receives a Content-Length or Transfer-Encoding header fields in a
      successful response, it MUST treat that response as malformed.

   *  A request message does not have content.

   *  A successful response message does not have content.

   *  Responses are not cacheable.

4.3.  Intermediary Processing

   Intermediaries MUST operate in one of the two following modes:

   Pass-through mode:  In this mode, the intermediary forwards the data
      stream between two associated streams without any modification of
      the data stream.

   Participant mode:  In this mode, the intermediary terminates the data
      stream and parses all Capsule Type and Capsule Length fields it
      receives.

   Each Capsule Type determines whether it is opaque or transparent to
   intermediaries in participant mode: opaque capsules are forwarded
   unmodified while transparent ones can be parsed, added, or removed by
   intermediaries.  Intermediaries MAY modify the contents of the
   Capsule Data field of transparent capsule types.

   Unless otherwise specified, all Capsule Types are defined as opaque
   to intermediaries.  Intermediaries MUST forward all received opaque
   CAPSULE frames in their unmodified entirety.  Intermediaries MUST NOT
   send any opaque CAPSULE frames other than the ones it is forwarding.
   All Capsule Types defined in this document are opaque, with the
   exception of the DATAGRAM Capsule, see Section 4.4. 4.4.4.  Definitions of
   new Capsule Types MAY specify that the newly introduced type is
   transparent.  Intermediaries MUST treat unknown Capsule Types as
   opaque.

   Intermediaries respect the order of opaque CAPSULE frames: if an
   intermediary receives two opaque CAPSULE frames in a given order, it
   MUST forward them in the same order.

   Endpoints which receive a Capsule with an unknown Capsule Type MUST
   silently drop that Capsule.

   Receipt of a CAPSULE HTTP/3 Frame on a stream that is not a client-
   initiated bidirectional stream MUST be treated as a connection error
   of type H3_FRAME_UNEXPECTED.

4.1.

4.4.  Capsule Types

4.4.1.  The REGISTER_DATAGRAM_CONTEXT Capsule

   The REGISTER_DATAGRAM_CONTEXT capsule (type=0x00) (see Section 8.2 for the value
   of the capsule type) allows an endpoint to inform its peer of the
   encoding and semantics of datagrams associated with a given context
   ID.  Its Capsule Data field consists
   of:

   REGISTER_DATAGRAM_CONTEXT Capsule {
     Type (i) = REGISTER_DATAGRAM_CONTEXT,
     Length (i),
     Context ID (i),
     Context Extensions
     Datagram Format Type (i),
     Datagram Format Additional Data (..),
   }

             Figure 3: 4: REGISTER_DATAGRAM_CONTEXT Capsule Format

   Context ID:  The context ID to register.

   Context Extensions:  See Section 5.

   Note

   Datagram Format Type:  A variable-length integer that these registrations are unilateral and bidirectional: defines the
      semantics and encoding of the HTTP Datagram Payload field of
      datagrams with this context ID, see Section 2.2.

   Datagram Format Additional Data:  This field carries additional
      information that impact the format of datagrams with this context
      ID, see Section 2.2.

   Note that these registrations are unilateral and bidirectional: the
   sender of the frame unilaterally defines the semantics it will apply
   to the datagrams it sends and receives using this context ID.  Once a
   context ID is registered, it can be used in both directions.

   Endpoints MUST NOT send DATAGRAM frames using a Context ID until they
   have either sent or received a REGISTER_DATAGRAM_CONTEXT Capsule with
   the same Context ID.  However, due to reordering, an endpoint that
   receives a reordering can cause DATAGRAM frame frames
   to be received with an unknown Context ID ID.  Receipt of such frames
   MUST NOT treat
   it be treated as an error, it error.  Endpoints SHALL instead drop the DATAGRAM
   frame silently, or buffer it temporarily while awaiting the
   corresponding REGISTER_DATAGRAM_CONTEXT Capsule.  Intermediaries
   SHALL drop the DATAGRAM frame silently, MAY buffer it, or forward it
   on immediately.

   Endpoints MUST NOT register the same Context ID twice on the same
   stream.  This also applies to Context IDs that have been closed using
   a CLOSE_DATAGRAM_CONTEXT capsule.  Clients MUST NOT register server-
   initiated Context IDs and servers MUST NOT register client-initiated
   Context IDs.  If an endpoint receives a REGISTER_DATAGRAM_CONTEXT
   capsule that violates one or more of these requirements, the endpoint
   MUST abruptly terminate the corresponding stream with a stream error
   of type H3_GENERAL_PROTOCOL_ERROR.

   Endpoints MUST NOT send a REGISTER_DATAGRAM_CONTEXT capsule on a
   stream before they have sent at least one HEADERS frame on that
   stream.  This removes the need to buffer REGISTER_DATAGRAM_CONTEXT
   capsules when the endpoint needs information from headers to
   determine how to react to the capsule.  If an endpoint receives a
   REGISTER_DATAGRAM_CONTEXT capsule on a stream that hasn't yet
   received a HEADERS frame, the endpoint MUST abruptly terminate the
   corresponding stream with a stream error of type
   H3_GENERAL_PROTOCOL_ERROR.

   Servers MUST NOT send a REGISTER_DATAGRAM_CONTEXT capsule on a stream
   before they have received at least one REGISTER_DATAGRAM_CONTEXT
   capsule or one REGISTER_DATAGRAM_NO_CONTEXT capsule from the client
   on that stream.  This ensures that clients control whether datagrams
   are allowed for a given request.  If a client receives a
   REGISTER_DATAGRAM_CONTEXT capsule on a stream where the client has
   not yet sent a REGISTER_DATAGRAM_CONTEXT capsule, the client MUST
   abruptly terminate the corresponding stream with a stream error of
   type H3_GENERAL_PROTOCOL_ERROR.

   Servers MUST NOT send a REGISTER_DATAGRAM_CONTEXT capsule on a stream
   where it has received a REGISTER_DATAGRAM_NO_CONTEXT capsule.  If a
   client receives a REGISTER_DATAGRAM_CONTEXT capsule on a stream where
   the client has sent a REGISTER_DATAGRAM_NO_CONTEXT capsule, the
   client MUST abruptly terminate the corresponding stream with a stream
   error of type H3_GENERAL_PROTOCOL_ERROR.

4.2.

4.4.2.  The REGISTER_DATAGRAM_NO_CONTEXT Capsule

   The REGISTER_DATAGRAM_NO_CONTEXT capsule (type=0x03) (see Section 8.2 for the
   value of the capsule type) allows a client to inform the server that
   datagram contexts will not be used with this stream.  It also informs
   the server of the encoding and semantics of datagrams associated with
   this stream.  Its Capsule Data
   field consists of:

   REGISTER_DATAGRAM_NO_CONTEXT Capsule {
     Context Extensions
     Type (i) = REGISTER_DATAGRAM_NO_CONTEXT,
     Length (i),
     Datagram Format Type (i),
     Datagram Format Additional Data (..),
   }

           Figure 4: 5: REGISTER_DATAGRAM_NO_CONTEXT Capsule Format

   Context Extensions:  See

   Datagram Format Type:  A variable-length integer that defines the
      semantics and encoding of the HTTP Datagram Payload field of
      datagrams, see Section 5. 2.2.

   Datagram Format Additional Data:  This field carries additional
      information that impact the format of datagrams, see Section 2.2.

   Note that this registration is unilateral and bidirectional: the
   client unilaterally defines the semantics it will apply to the
   datagrams it sends and receives with this stream.

   Endpoints MUST NOT send DATAGRAM frames without a Context ID until
   they have either sent or received a REGISTER_DATAGRAM_NO_CONTEXT
   Capsule.  However, due to reordering, an endpoint that receives a
   DATAGRAM frame before receiving either a REGISTER_DATAGRAM_CONTEXT
   capsule or a REGISTER_DATAGRAM_NO_CONTEXT capsule MUST NOT treat it
   as an error, it SHALL instead drop the DATAGRAM frame silently, or
   buffer it temporarily while awaiting a REGISTER_DATAGRAM_NO_CONTEXT
   capsule or the corresponding REGISTER_DATAGRAM_CONTEXT capsule.

   Servers MUST NOT send the REGISTER_DATAGRAM_NO_CONTEXT capsule.  If a
   client receives a REGISTER_DATAGRAM_NO_CONTEXT capsule, the client
   MUST abruptly terminate the corresponding stream with a stream error
   of type H3_GENERAL_PROTOCOL_ERROR.

   Clients MUST NOT send more than one REGISTER_DATAGRAM_NO_CONTEXT
   capsule on a stream.  If a server receives a second
   REGISTER_DATAGRAM_NO_CONTEXT capsule on the same stream, the server
   MUST abruptly terminate the corresponding stream with a stream error
   of type H3_GENERAL_PROTOCOL_ERROR.

   Clients MUST NOT send a REGISTER_DATAGRAM_NO_CONTEXT capsule on a
   stream before they have sent at least one HEADERS frame on that
   stream.  This removes the need to buffer REGISTER_DATAGRAM_CONTEXT
   capsules when the server needs information from headers to determine
   how to react to the capsule.  If a server receives a
   REGISTER_DATAGRAM_NO_CONTEXT capsule on a stream that hasn't yet
   received a HEADERS frame, the server MUST abruptly terminate the
   corresponding stream with a stream error of type
   H3_GENERAL_PROTOCOL_ERROR.

   Clients MUST NOT send both REGISTER_DATAGRAM_CONTEXT capsules and
   REGISTER_DATAGRAM_NO_CONTEXT capsules on the same stream.  If a
   server receives both a REGISTER_DATAGRAM_CONTEXT capsule and both REGISTER_DATAGRAM_CONTEXT capsules and
   REGISTER_DATAGRAM_NO_CONTEXT capsules on the same stream.  If a
   server receives both a REGISTER_DATAGRAM_CONTEXT capsule and a
   REGISTER_DATAGRAM_NO_CONTEXT capsule on the same stream, the server
   MUST abruptly terminate the corresponding stream with a stream error
   of type H3_GENERAL_PROTOCOL_ERROR.

   Extensions MAY define a different mechanism to negotiate the presence
   of contexts, communicate whether
   contexts are in use, and they MAY do so in a way which is opaque to
   intermediaries.

4.3.

4.4.3.  The CLOSE_DATAGRAM_CONTEXT Capsule

   The CLOSE_DATAGRAM_CONTEXT capsule (type=0x01) (see Section 8.2 for the value of
   the capsule type) allows an endpoint to inform its peer that it will
   no longer send or parse received datagrams associated with a given
   context ID.  Its Capsule Data field
   consists of:

   CLOSE_DATAGRAM_CONTEXT Capsule {
     Type (i) = CLOSE_DATAGRAM_CONTEXT,
     Length (i),
     Context ID (i),
     Context Extensions
     Close Code (i),
     Close Details (..),
   }

              Figure 5: 6: CLOSE_DATAGRAM_CONTEXT Capsule Format

   Context ID:  The context ID to close.

   Context Extensions:  See

   Close Code:  The close code allows an endpoint to provide additional
      information as to why a datagram context was closed.
      Section 5. 4.4.3.1 defines a set of codes, the circumstances under
      which an implementation sends them, and how receivers react.

   Close Details:  This is meant for debugging purposes.  It consists of
      a human-readable string encoded in UTF-8.

   Note that this close is unilateral and bidirectional: the sender of
   the frame unilaterally informs its peer of the closure.  Endpoints
   can use CLOSE_DATAGRAM_CONTEXT capsules to close a context that was
   initially registered by either themselves, or by their peer.
   Endpoints MAY use the CLOSE_DATAGRAM_CONTEXT capsule to immediately
   reject a context that was just registered using a
   REGISTER_DATAGRAM_CONTEXT capsule if they find its Context Extensions Datagram Format
   Type field to be unacceptable.

   After an endpoint has either sent or received a
   CLOSE_DATAGRAM_CONTEXT frame, it MUST NOT send any DATAGRAM frames
   with that Context ID.  However, due to reordering, an endpoint that
   receives a DATAGRAM frame with a closed Context ID MUST NOT treat it
   as an error, it SHALL instead drop the DATAGRAM frame silently.

   Endpoints MUST NOT close a Context ID that was not previously
   registered.  Endpoints MUST NOT close a Context ID that has already
   been closed.  If an endpoint receives a CLOSE_DATAGRAM_CONTEXT
   capsule that violates one or more of these requirements, the endpoint
   MUST abruptly terminate the corresponding stream with a stream error
   of type H3_GENERAL_PROTOCOL_ERROR.

   All CLOSE_DATAGRAM_CONTEXT capsules MUST contain a CLOSE_CODE

4.4.3.1.  Close Codes

   Close codes are intended to allow implementations to react
   differently when they receive them - for example, some close codes
   require the receiver to not open another context
   extension, see under certain
   conditions.

   This specification defines the close codes below.  Their numeric
   values are in Section 5.1.  If an endpoint receives a
   CLOSE_DATAGRAM_CONTEXT capsule without 8.4.  Extensions to this mechanism MAY define
   new close codes and they SHOULD state how receivers react to them.

   NO_ERROR:  This indicates that a CLOSE_CODE context
   extension, the endpoint MUST abruptly terminate was closed without any
      action specified for the corresponding
   stream receiver.

   UNKNOWN_FORMAT:  This indicates that the sender does not know how to
      interpret the datagram format type associated with a stream error of this context.
      The endpoint that had originally registered this context MUST NOT
      try to register another context with the same datagram format type H3_GENERAL_PROTOCOL_ERROR.

4.4.
      on this stream.

   DENIED:  This indicates that the sender has rejected the context
      registration based on its local policy.  The endpoint that had
      originally registered this context MUST NOT try to register
      another context with the same datagram format type and datagram
      format data on this stream.

   RESOURCE_LIMIT:  This indicates that the context was closed to save
      resources.  The recipient SHOULD limit its future registration of
      resource-intensive contexts.

   Receipt of an unknown close code MUST be treated as if the NO_ERROR
   code was present.  Close codes are registered with IANA, see
   Section 8.4.

4.4.4.  The DATAGRAM Capsule

   The DATAGRAM capsule (type=0x02) (see Section 8.2 for the value of the capsule
   type) allows an endpoint to send a datagram frame over an HTTP
   stream.  This is particularly useful when using a version of HTTP
   that does not support QUIC DATAGRAM frames.
   Its Capsule Data field consists of:

   DATAGRAM Capsule {
     Type (i) = DATAGRAM,
     Length (i),
     [Context ID (i)],
     HTTP Datagram Payload (..),
   }

                     Figure 6: 7: DATAGRAM Capsule Format

   Context ID:  A variable-length integer indicating the context ID of
      the datagram (see Section 2.1).  Whether or not this field is
      present depends on which registration capsules were exchanged on
      the associated stream: if a REGISTER_DATAGRAM_CONTEXT capsule (see
      Section 4.1) 4.4.1) has been sent or received on this stream, then the
      field is present; if a REGISTER_DATAGRAM_NO_CONTEXT capsule (see
      Section 4.2) 4.4.2) has been sent or received, then this field is
      absent; if neither has been sent or received, then it is not yet
      possible to parse this datagram and the receiver MUST either drop
      that datagram silently or buffer it temporarily while awaiting the
      registration capsule.

   HTTP Datagram Payload:  The payload of the datagram, whose semantics
      are defined by individual applications.  Note that this field can
      be empty.

   Datagrams sent using the DATAGRAM Capsule have the exact same
   semantics as datagrams sent in QUIC DATAGRAM frames.  In particular,
   the restrictions on when it is allowed to send an HTTP Datagram and
   how to process them from Section 3 also apply to HTTP Datagrams sent
   and received using the DATAGRAM capsule.

   The DATAGRAM Capsule is transparent to intermediaries, meaning that
   intermediaries MAY parse it and send DATAGRAM Capsules that they did
   not receive.  This allows an intermediary to reencode HTTP Datagrams
   as it forwards them: in other words, an intermediary MAY send a
   DATAGRAM Capsule to forward an HTTP Datagram which was received in a
   QUIC DATAGRAM frame, and vice versa.

   Note that while DATAGRAM capsules are sent on a stream,
   intermediaries can reencode HTTP Datagrams into QUIC DATAGRAM frames
   over the next hop, and those could be dropped.  Because of this,
   applications have to always consider HTTP Datagrams to be unreliable,
   even if they were initially sent in a capsule.

5.  Context Extensibility

   In order to facilitate extensibility of contexts, the
   REGISTER_DATAGRAM_CONTEXT, REGISTER_DATAGRAM_NO_CONTEXT, and the
   CLOSE_DATAGRAM_CONTEXT capsules carry a Context Extensions field.
   That field contains

   If an intermediary receives an HTTP Datagram in a sequence of context extensions:

     Context Extensions {
       Context Extension (..) ...,
     }

   Each context extension QUIC DATAGRAM frame
   and is encoded as forwarding it on a (type, length, value) tuple:

     Context Extension {
       Context Extension Type (i),
       Context Extension Length (i),
       Context Extension Value (..),
     }

   Context Extension Types are registered with IANA, see Section 10.4.
   The Context Extension Length field contains the length of the Context
   Extension Value field in bytes.  The semantics of the Context
   Extension Value field are defined by connection that supports QUIC DATAGRAM
   frames, the corresponding Context
   Extension Type.

5.1.  The CLOSE_CODE Context Extension Type

   The CLOSE_CODE context extension type (type=0x00) allows an endpoint
   to provide additional information as intermediary SHOULD NOT convert that HTTP Datagram to why a datagram context was
   closed.  This type SHALL only be sent
   DATAGRAM capsule.  If the HTTP Datagram is too large to fit in CLOSE_DATAGRAM_CONTEXT
   capsules.  Its Context Extension Value field consists of a single
   variable-length integer which contains
   DATAGRAM frame (for example because the close code.  The following
   codes are defined:

   NO_ERROR (code=0x00):  This indicates path MTU of that QUIC
   connection is too low or if the registration was
      closed without any additional information.

   DENIED (code=0x01):  This indicates maximum UDP payload size advertised
   on that connection is too low), the sender has rejected intermediary SHOULD drop the
      context registration based on its local policy.  The endpoint that
      had originally registered this context MUST NOT try HTTP
   Datagram instead of converting it to register
      another context with the same context extensions on this stream.

   RESOURCE_LIMIT (code=0x02): a DATAGRAM capsule.  This indicates that
   preserves the context was
      closed to save resources.  The recipient SHOULD limit its future
      registration of resource-incentive contexts.

   Receipt of an unknown close code MUST be treated end-to-end unreliability characteristic that methods
   such as if the NO_ERROR
   code was present.  Close codes are registered with IANA, see
   Section 10.5.

5.2.  The DETAILS Context Extension Type

   The DETAILS context extension type (type=0x01) allows an endpoint Datagram Packetization Layer Path MTU Discovery (DPLPMTUD)
   depend on [RFC8899].  An intermediary that converts QUIC DATAGRAM
   frames to
   provide additional details DATAGRAM capsules allows HTTP Datagrams to context capsules.  It is meant for
   debugging purposes.  Its Context Extension Value field consists of be arbitrarily
   large without suffering any loss; this can misrepresent the true path
   properties, defeating methods such a
   human-readable string encoded in UTF-8.

6. DPLPMTUD.

5.  The H3_DATAGRAM HTTP/3 SETTINGS Parameter

   Implementations of HTTP/3 that support this mechanism HTTP Datagrams can indicate
   that to their peer by sending the H3_DATAGRAM SETTINGS parameter with
   a value of 1.  The value of the H3_DATAGRAM SETTINGS parameter MUST
   be either 0 or 1.  A value of 0 indicates that this mechanism is HTTP Datagrams are not
   supported.  An endpoint that receives the H3_DATAGRAM SETTINGS
   parameter with a value that is neither 0 or 1 MUST terminate the
   connection with error H3_SETTINGS_ERROR.

   An endpoint that sends the H3_DATAGRAM SETTINGS parameter with a
   value of 1

   Endpoints MUST NOT send the max_datagram_frame_size QUIC Transport
   Parameter [DGRAM].  An endpoint that receives DATAGRAM frames until they have both
   sent and received the H3_DATAGRAM SETTINGS parameter with a value of 1 on a QUIC connection that did
   not also receive the max_datagram_frame_size QUIC Transport Parameter
   MUST terminate the connection with error H3_SETTINGS_ERROR.
   1.

   When clients use 0-RTT, they MAY store the value of the server's
   H3_DATAGRAM SETTINGS parameter.  Doing so allows the client to use
   HTTP/3 datagrams send
   QUIC DATAGRAM frames in 0-RTT packets.  When servers decide to accept
   0-RTT data, they MUST send a H3_DATAGRAM SETTINGS parameter greater
   than or equal to the value they sent to the client in the connection
   where they sent them the NewSessionTicket message.  If a client
   stores the value of the H3_DATAGRAM SETTINGS parameter with their
   0-RTT state, they MUST validate that the new value of the H3_DATAGRAM
   SETTINGS parameter sent by the server in the handshake is greater
   than or equal to the stored value; if not, the client MUST terminate
   the connection with error H3_SETTINGS_ERROR.  In all cases, the
   maximum permitted value of the H3_DATAGRAM SETTINGS parameter is 1.

7.  Prioritization

   Prioritization

5.1.  Note About Draft Versions

   [[RFC editor: please remove this section before publication.]]

   Some revisions of HTTP/3 datagrams is not defined in this document.
   Future extensions MAY define how draft specification use a different value (the
   Identifier field of a Setting in the HTTP/3 SETTINGS frame) for the
   H3_DATAGRAM Settings Parameter.  This allows new draft revisions to prioritize datagrams, and
   make incompatible changes.  Multiple draft versions MAY
   define signaling to allow be supported
   by either endpoint in a connection.  Such endpoints to communicate their
   prioritization preferences.

8.  HTTP/1.x MUST send
   multiple values for H3_DATAGRAM.  Once an endpoint has sent and HTTP/2 Support

   We can provide DATAGRAM support in HTTP/2 by defining
   received SETTINGS, it MUST compute the CAPSULE
   frame in HTTP/2.

   We intersection of the values it
   has sent and received, and then it MUST select and use the most
   recent draft version from the intersection set.  This ensures that
   both endpoints negotiate the same draft version.

6.  Prioritization

   Data streams (see Section 4.1) can provide DATAGRAM support in HTTP/1.x by defining its data
   stream format be prioritized using any means
   suited to a sequence stream or request prioritization.  For example, see
   Section 11 of [PRIORITY].

   Prioritization of length-value capsules.

   TODO: Refactor HTTP/3 datagrams is not defined in this document and add definitions for HTTP/1.x document.
   Future extensions MAY define how to prioritize datagrams, and
   HTTP/2.

9. MAY
   define signaling to allow endpoints to communicate their
   prioritization preferences.

7.  Security Considerations

   Since this feature requires sending an HTTP/3 Settings parameter, it
   "sticks out".  In other words, probing clients can learn whether a
   server supports this feature.  Implementations that support this
   feature SHOULD always send this Settings parameter to avoid leaking
   the fact that there are applications using HTTP/3 datagrams enabled
   on this endpoint.

10.

8.  IANA Considerations

10.1.  HTTP/3 CAPSULE Frame

   This document will request IANA to register the following entry in
   the "HTTP/3 Frames" registry:

     +------------+----------+---------------+
     | Frame Type |   Value  | Specification |
     +============+==========+===============+
     |  CAPSULE   | 0xffcab5 | This Document |
     +------------+----------+---------------+

10.2.

8.1.  HTTP/3 SETTINGS Parameter

   This document will request IANA to register the following entry in
   the "HTTP/3 Settings" registry:

     +--------------+----------+---------------+---------+

           +==============+==========+===============+=========+
           | Setting Name | Value    | Specification | Default |
           +==============+==========+===============+=========+
           | H3_DATAGRAM  | 0xffd276 0xffd277 | This Document | 0       |
           +--------------+----------+---------------+---------+

10.3.

                        Table 1: New HTTP/3 Settings

8.2.  Capsule Types

   This document establishes a registry for HTTP capsule type codes.
   The "HTTP Capsule Types" registry governs a 62-bit space.
   Registrations in this registry MUST include the following fields:

   Type:  A name or label for the capsule type.

   Value:  The value of the Capsule Type field (see Section 4) 4.1) is a
      62bit
      62-bit integer.

   Reference:  An optional reference to a specification for the type.
      This field MAY be empty.

   Registrations follow the "First Come First Served" policy (see
   Section 4.4 of [IANA-POLICY]) where two registrations MUST NOT have
   the same Type.

   This registry initially contains the following entries:

   +------------------------------+-------+---------------+

        +==============================+==========+===============+
        | Capsule Type                 | Value    | Specification |
   +------------------------------+-------+---------------+
        +==============================+==========+===============+
        | REGISTER_DATAGRAM_CONTEXT DATAGRAM                     | 0x00 0xff37a0 | This Document |
   +------------------------------+-------+---------------+
        +------------------------------+----------+---------------+
        | CLOSE_DATAGRAM_CONTEXT REGISTER_DATAGRAM_CONTEXT    | 0x01 0xff37a1 | This Document |
   +------------------------------+-------+---------------+
        +------------------------------+----------+---------------+
        | DATAGRAM REGISTER_DATAGRAM_NO_CONTEXT | 0x02 0xff37a2 | This Document |
   +------------------------------+-------+---------------+
        +------------------------------+----------+---------------+
        | REGISTER_DATAGRAM_NO_CONTEXT CLOSE_DATAGRAM_CONTEXT       | 0x03 0xff37a3 | This Document |
   +------------------------------+-------+---------------+
        +------------------------------+----------+---------------+

              Table 2: Initial Capsule Types Registry Entries

   Capsule types with a value of the form 41 * N + 23 for integer values
   of N are reserved to exercise the requirement that unknown capsule
   types be ignored.  These capsules have no semantics and can carry
   arbitrary values.  These values MUST NOT be assigned by IANA and MUST
   NOT appear in the listing of assigned values.

10.4.  Context Extension

8.3.  Datagram Format Types

   This document establishes a registry for HTTP datagram context
   extension format type
   codes.  The "HTTP Context Extension Datagram Format Types" registry governs a 62-bit
   space.  Registrations in this registry MUST include the following
   fields:

   Type:  A name or label for the context extension datagram format type.

   Value:  The value of the Context Extension Datagram Format Type field (see Section 5) 2.2)
      is a 62bit 62-bit integer.

   Reference:  An optional reference to a specification for the
      parameter.  This field MAY be empty.

   Registrations follow the "First Come First Served" policy (see
   Section 4.4 of [IANA-POLICY]) where two registrations MUST NOT have
   the same Type nor Value.

   This registry is initially contains the following entries:

   +------------------------------+-------+---------------+
   | Context Extension Type       | Value | Specification |
   +------------------------------+-------+---------------+
   | CLOSE_CODE                   | 0x00  | This Document |
   +------------------------------+-------+---------------+
   | DETAILS                      | 0x01  | This Document |
   +------------------------------+-------+---------------+
   Context extension empty.

   Datagram format types with a value of the form 41 * N + 17 for
   integer values of N are reserved to exercise the requirement that
   unknown context extension datagram format types be ignored.  These extensions format types have no
   semantics and can carry arbitrary values.  These values MUST NOT be
   assigned by IANA and MUST NOT appear in the listing of assigned
   values.

10.5.

8.4.  Context Close Codes

   This document establishes a registry for HTTP context extension type close codes.
   The "HTTP Context Close Codes" registry governs a 62-bit space.
   Registrations in this registry MUST include the following fields:

   Type:  A name or label for the close code.

   Value:  The value of the CLOSE_CODE Context Extension Value Close Code field (see Section 5.1) 4.4.3) is a 62bit
      62-bit integer.

   Reference:  An optional reference to a specification for the
      parameter.  This field MAY be empty.

   Registrations follow the "First Come First Served" policy (see
   Section 4.4 of [IANA-POLICY]) where two registrations MUST NOT have
   the same Type nor Value.

   This registry initially contains the following entries:

   +------------------------------+-------+---------------+

             +====================+==========+===============+
             | Context Close Code | Value    | Specification |
   +------------------------------+-------+---------------+
             +====================+==========+===============+
             | NO_ERROR           | 0x00 0xff78a0 | This Document |
             +--------------------+----------+---------------+
             | UNKNOWN_FORMAT     | 0xff78a1 | This Document |
   +------------------------------+-------+---------------+
             +--------------------+----------+---------------+
             | DENIED             | 0x01 0xff78a2 | This Document |
   +------------------------------+-------+---------------+
             +--------------------+----------+---------------+
             | RESOURCE_LIMIT     | 0x02 0xff78a3 | This Document |
   +------------------------------+-------+---------------+
             +--------------------+----------+---------------+

                Table 3: Initial Context Close Code Registry
                                  Entries

   Context close codes with a value of the form 41 * N + 19 for integer
   values of N are reserved to exercise the requirement that unknown
   context close codes be treated as NO_ERROR.  These values MUST NOT be
   assigned by IANA and MUST NOT appear in the listing of assigned
   values.

11.

9.  References

9.1.  Normative References

   [DGRAM]    Pauly, T., Kinnear, E., and D. Schinazi, "An Unreliable
              Datagram Extension to QUIC", Work in Progress, Internet-
              Draft, draft-ietf-quic-datagram-03, 12 July draft-ietf-quic-datagram-06, 5 October 2021,
              <https://datatracker.ietf.org/doc/html/draft-ietf-quic-
              datagram-03>.
              datagram-06>.

   [H3]       Bishop, M., "Hypertext Transfer Protocol Version 3
              (HTTP/3)", Work in Progress, Internet-Draft, draft-ietf-
              quic-http-34, 2 February 2021,
              <https://datatracker.ietf.org/doc/html/draft-ietf-quic-
              http-34>.

   [IANA-POLICY]
              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/rfc/rfc8126>.

   [QUIC]     Iyengar, J. J., Ed. and M. Thomson, Ed., "QUIC: A UDP-Based
              Multiplexed and Secure Transport", Work in Progress, Internet-Draft,
              draft-ietf-quic-transport-34, 14 January RFC 9000,
              DOI 10.17487/RFC9000, May 2021,
              <https://datatracker.ietf.org/doc/html/draft-ietf-quic-
              transport-34>.
              <https://www.rfc-editor.org/rfc/rfc9000>.

   [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/rfc/rfc2119>.

   [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/rfc/rfc8174>.

9.2.  Informative References

   [PRIORITY] Oku, K. and L. Pardue, "Extensible Prioritization Scheme
              for HTTP", Work in Progress, Internet-Draft, draft-ietf-
              httpbis-priority-06, 30 September 2021,
              <https://datatracker.ietf.org/doc/html/draft-ietf-httpbis-
              priority-06>.

   [RFC8899]  Fairhurst, G., Jones, T., Tüxen, M., Rüngeler, I., and T.
              Völker, "Packetization Layer Path MTU Discovery for
              Datagram Transports", RFC 8899, DOI 10.17487/RFC8899,
              September 2020, <https://www.rfc-editor.org/rfc/rfc8899>.

Appendix A.  Examples

A.1.  CONNECT-UDP

   Client                                             Server

   STREAM(44): HEADERS             -------->
     :method = CONNECT-UDP
     :scheme = https
     :path = /
     :authority = target.example.org:443

   STREAM(44): CAPSULE DATA                -------->
     Capsule Type = REGISTER_DATAGRAM_CONTEXT
     Context ID = 0
     Context Extension
     Datagram Format Type = UDP_PAYLOAD
     Datagram Format Additional Data = {} ""

   DATAGRAM                        -------->
     Quarter Stream ID = 11
     Context ID = 0
     Payload = Encapsulated UDP Payload

              <--------  STREAM(44): HEADERS
                           :status = 200

   /* Wait for target server to respond to UDP packet. */

              <--------  DATAGRAM
                           Quarter Stream ID = 11
                           Context ID = 0
                           Payload = Encapsulated UDP Payload

A.2.  CONNECT-UDP with Timestamp Extension
   Client                                             Server

   STREAM(44): HEADERS            -------->
     :method = CONNECT-UDP
     :scheme = https
     :path = /
     :authority = target.example.org:443

   STREAM(44): CAPSULE DATA               -------->
     Capsule Type = REGISTER_DATAGRAM_CONTEXT
     Context ID = 0
     Context Extension
     Datagram Format Type = {} UDP_PAYLOAD
     Datagram Format Additional Data = ""

   DATAGRAM                       -------->
     Quarter Stream ID = 11
     Context ID = 0
     Payload = Encapsulated UDP Payload

              <--------  STREAM(44): HEADERS
                           :status = 200

   /* Wait for target server to respond to UDP packet. */

              <--------  DATAGRAM
                           Quarter Stream ID = 11
                           Context ID = 0
                           Payload = Encapsulated UDP Payload

   STREAM(44): CAPSULE DATA               -------->
     Capsule Type = REGISTER_DATAGRAM_CONTEXT
     Context ID = 2
     Context Extension
     Datagram Format Type = UDP_PAYLOAD_WITH_TIMESTAMP
     Datagram Format Additional Data = {TIMESTAMP=""} ""

   DATAGRAM                       -------->
     Quarter Stream ID = 11
     Context ID = 2
     Payload = Encapsulated UDP Payload With Timestamp

A.3.  CONNECT-IP with IP compression
   Client                                             Server

   STREAM(44): HEADERS            -------->
     :method = CONNECT-IP
     :scheme = https
     :path = /
     :authority = proxy.example.org:443

              <--------  STREAM(44): HEADERS
                           :status = 200

   /* Exchange CONNECT-IP configuration information. */

   STREAM(44): CAPSULE DATA                -------->
     Capsule Type = REGISTER_DATAGRAM_CONTEXT
     Context ID = 0
   Context Extension
     Datagram Format Type = IP_PACKET
     Datagram Format Additional Data = {} ""

   DATAGRAM                       -------->
     Quarter Stream ID = 11
     Context ID = 0
     Payload = Encapsulated IP Packet

   /* Endpoint happily exchange encapsulated IP packets */
   /* using Quarter Stream ID 11 and Context ID 0.      */

   DATAGRAM                       -------->
     Quarter Stream ID = 11
     Context ID = 0
     Payload = Encapsulated IP Packet

   /* After performing some analysis on traffic patterns, */
   /* the client decides it wants to compress a 5-tuple. 2-tuple.  */

   STREAM(44): CAPSULE DATA                -------->
     Capsule Type = REGISTER_DATAGRAM_CONTEXT
     Context ID = 2
   Context Extension
     Datagram Format Type = COMPRESSED_IP_PACKET
     Datagram Format Additional Data = {IP_COMPRESSION=tcp,192.0.2.6:9876,192.0.2.7:443} "192.0.2.6,192.0.2.7"

   DATAGRAM                       -------->
     Quarter Stream ID = 11
     Context ID = 2
     Payload = Compressed IP Packet

A.4.  WebTransport

   Client                                             Server

   STREAM(44): HEADERS            -------->
     :method = CONNECT
     :scheme = https
     :method = webtransport
     :path = /hello
     :authority = webtransport.example.org:443
     Origin = https://www.example.org:443

   STREAM(44): CAPSULE DATA                -------->
     Capsule Type = REGISTER_DATAGRAM_NO_CONTEXT
     Context Extension
     Datagram Format Type = WEBTRANSPORT_DATAGRAM
     Datagram Format Additional Data = {} ""

              <--------  STREAM(44): HEADERS
                           :status = 200

   /* Both endpoints can now send WebTransport datagrams. */

Acknowledgments

   The DATAGRAM context identifier was previously part of the DATAGRAM
   frame definition itself, the authors would like to acknowledge the
   authors of that document and the members of the IETF MASQUE working
   group for their suggestions.  Additionally, the authors would like to
   thank Martin Thomson for suggesting the use of an HTTP/3 SETTINGS
   parameter.  Furthermore, the authors would like to thank Ben Schwartz
   for writing the first proposal that used two layers of indirection.

Authors' Addresses

   David Schinazi
   Google LLC
   1600 Amphitheatre Parkway
   Mountain View, California 94043,
   United States of America

   Email: dschinazi.ietf@gmail.com

   Lucas Pardue
   Cloudflare

   Email: lucaspardue.24.7@gmail.com