<?xml version="1.0" encoding="UTF-8"?>
  <?xml-stylesheet type="text/xsl" href="rfc2629.xslt" ?>
  <!-- generated by https://github.com/cabo/kramdown-rfc2629 version 1.0.30 -->

<!DOCTYPE rfc SYSTEM "rfc2629.dtd" [
]>

<?rfc toc="yes"?>
<?rfc sortrefs="yes"?>
<?rfc symrefs="yes"?>
<?rfc docmapping="yes"?>

<rfc ipr="trust200902" docName="draft-ietf-quic-http-00" category="std">

  <feedback xmlns='http://purl.org/net/xml2rfc/ext' template="mailto:quic@ietf.org?subject={docname},%20%22{section}%22&amp;body=%3c{ref}%3e:"/><front>
    <title abbrev="HTTP over QUIC">Hypertext Transfer Protocol (HTTP) over QUIC</title>

    <author initials="M." surname="Bishop" fullname="Mike Bishop" role="editor">
      <organization>Microsoft</organization>
      <address>
        <email>Mike.Bishop@microsoft.com</email>
      </address>
    </author>

    <date year="2016" month="11" day="28"/>

    <area>Transport</area>
    <workgroup>QUIC</workgroup>
    

    <abstract>


<t>The QUIC transport protocol has several features that are desirable in a
transport for HTTP/2, such as stream multiplexing, per-stream flow control, and
low-latency connection establishment.  This document describes a mapping of
HTTP/2 semantics over QUIC.  Specifically, this document identifies HTTP/2
features that are subsumed by QUIC, and describes how the other features can be
implemented atop QUIC.</t>



    </abstract>


  </front>

  <middle>


<section anchor="introduction" title="Introduction">

<t>The QUIC transport protocol has several features that are desirable in a
transport for HTTP/2, such as stream multiplexing, per-stream flow control, and
low-latency connection establishment.  This document describes a mapping of
HTTP/2 semantics over QUIC.  Specifically, this document identifies HTTP/2
features that are subsumed by QUIC, and describes how the other features can be
implemented atop QUIC.</t>

<t>QUIC is described in <xref target="QUIC-TRANSPORT"/>.  For a full description of HTTP/2, see
<xref target="RFC7540"/>.</t>

<section anchor="notational-conventions" title="Notational Conventions">

<t>The words “MUST”, “MUST NOT”, “SHOULD”, and “MAY” are used in this document.
It’s not shouting; when they are capitalized, they have the special meaning
defined in <xref target="RFC2119"/>.</t>

</section>
</section>
<section anchor="quic-advertisement" title="QUIC advertisement">

<t>A server advertises that it can speak HTTP/2-over-QUIC via the Alt- Svc HTTP
response header.  It does so by including the header in any response sent over a
non-QUIC (e.g.  HTTP/2 over TLS) connection:</t>

<t>Alt-Svc: quic=”:443”</t>

<t>In addition, the list of QUIC versions supported by the server can be specified
by the v= parameter.  For example, if a server supported both version 33 and 34
it would specify the following header:</t>

<t>Alt-Svc: quic=”:443”; v=”34,33”</t>

<t>On receipt of this header, a client may attempt to establish a QUIC connection
on port 443 and, if successful, send HTTP/2 requests using the mapping described
in this document.</t>

<t>Connectivity problems (e.g. firewall blocking UDP) may result in QUIC connection
establishment failure, in which case the client should gracefully fallback to
HTTP/2-over-TLS/TCP.</t>

</section>
<section anchor="connection-establishment" title="Connection establishment">

<t>HTTP/2-over-QUIC connections are established as described in <xref target="QUIC-TRANSPORT"/>.
The QUIC crypto handshake MUST use TLS <xref target="QUIC-TLS"/>.</t>

<t>While connection-level options pertaining to the core QUIC protocol are set in
the initial crypto handshake <xref target="QUIC-TLS"/>.  HTTP/2-specific settings are
conveyed in the HTTP/2 SETTINGS frame.  After the QUIC connection is
established, an HTTP/2 SETTINGS frame may be sent as the initial frame of the
QUIC headers stream (StreamID 3, See <xref target="stream-mapping"/>). As in HTTP/2,
additional SETTINGS frames may be sent mid-connection by either endpoint.</t>

<t><list style="hanging">
  <t hangText='TODO:'>
  Decide whether to acknowledge receipt of SETTINGS through empty SETTINGS
frames with ACK bit set, as in HTTP/2, or rely on transport- level
acknowledgment.</t>
</list></t>

<t>Some transport-level options that HTTP/2-over-TCP specifies via the SETTINGS
frame are superseded by QUIC transport parameters in HTTP/2- over-QUIC.  Below
is a listing of how each HTTP/2 SETTINGS parameter is mapped:</t>

<t><list style="hanging">
  <t hangText='SETTINGS_HEADER_TABLE_SIZE:'>
  Sent in HTTP/2 SETTINGS frame.</t>
  <t hangText='SETTINGS_ENABLE_PUSH:'>
  Sent in HTTP/2 SETTINGS frame (TBD, currently set using QUIC “SPSH” connection
option)</t>
  <t hangText='SETTINGS_MAX_CONCURRENT_STREAMS'>
  QUIC requires the maximum number of incoming streams per connection to be
specified in the initial crypto handshake, using the “MSPC” tag.  Specifying
SETTINGS_MAX_CONCURRENT_STREAMS in the HTTP/2 SETTINGS frame is an error.</t>
  <t hangText='SETTINGS_INITIAL_WINDOW_SIZE:'>
  QUIC requires both stream and connection flow control window sizes to be
specified in the initial crypto handshake, using the “SFCW” and “CFCW” tags,
respectively.  Specifying SETTINGS_INITIAL_WINDOW_SIZE in the HTTP/2 SETTINGS
frame is an error.</t>
  <t hangText='SETTINGS_MAX_FRAME_SIZE:'>
  This setting has no equivalent in QUIC.  Specifying it in the HTTP/2 SETTINGS
frame is an error.</t>
  <t hangText='SETTINGS_MAX_HEADER_LIST_SIZE'>
  Sent in HTTP/2 SETTINGS frame.</t>
</list></t>

<t>As with HTTP/2-over-TCP, unknown SETTINGS parameters are tolerated but ignored.
SETTINGS parameters are acknowledged by the receiving peer, by sending an empty
SETTINGS frame in response with the ACK bit set.</t>

</section>
<section anchor="sending-a-request-on-an-http2-over-quic-connection" title="Sending a request on an HTTP/2-over-QUIC connection">

<t>A high level overview of sending an HTTP/2 request on an established QUIC
connection is as follows, with further details in later sections of this
document.  A client should first encode any HTTP headers using HPACK
<xref target="RFC7541"/> and frame them as HTTP/2 HEADERS frames.  These are sent on
StreamID 3 (see <xref target="stream-mapping"/>).  The exact layout of the HEADERS frame is
described in Section 6.2 of <xref target="RFC7540"/>.  No HTTP/2 padding is required: QUIC
provides a PADDING frame for this purpose.</t>

<t>While HEADERS are sent on stream 3, the mandatory stream identifier in each
HEADERS frame indicates the QUIC StreamID on which a corresponding request body
may be sent.  If there is no non-header data, the specified QUIC data stream
will never be used.</t>

<section anchor="terminating-a-stream" title="Terminating a stream">

<t>A stream can be terminated in one of three ways:</t>

<t><list style="symbols">
  <t>the request/response is headers only, in which case a HEADERS frame with the
END_STREAM bit set ends the stream specified in the HEADERS frame</t>
  <t>the request/response has headers and body but no trailing headers, in which
case the final QUIC STREAM frame will have the FIN bit set</t>
  <t>the request/response has headers, body, and trailing headers, in which case
the final QUIC STREAM frame will not have the FIN bit set, and the trailing
HEADERS frame will have the END_STREAM bit set</t>
</list></t>

<t>(TODO: Describe mapping of HTTP/2 stream state machine to QUIC stream state
machine.)</t>

</section>
</section>
<section anchor="writing-data-to-quic-streams" title="Writing data to QUIC streams">

<t>A QUIC stream provides reliable in-order delivery of bytes, within that stream.
On the wire, data is framed into QUIC STREAM frames, but this framing is
invisible to the HTTP/2 layer.  A QUIC receiver buffers and orders received
STREAM frames, exposing the data contained within as a reliable byte stream to
the application.</t>

<t>Bytes written to Stream 3 must be HTTP/2 HEADERS frames (or other HTTP/2
non-data frames), whereas bytes written to data streams should simply be request
or response bodies.  No further framing is required by HTTP/2 (i.e. no HTTP/2
DATA frames are used).</t>

<t>If data arrives on a data stream before the corresponding HEADERS have arrived
on stream 3, then the data is buffered until the HEADERS arrive.</t>

</section>
<section anchor="stream-mapping" title="Stream Mapping">

<t>When HTTP/2 headers and data are sent over QUIC, the QUIC layer handles most of
the stream management.  HTTP/2 StreamIDs are replaced by QUIC StreamIDs.  HTTP/2
does not need to do any explicit stream framing when using QUIC - data sent over
a QUIC stream simply consists of HTTP/2 headers or body.  Requests and responses
are considered complete when the QUIC stream is closed in the corresponding
direction.</t>

<t>Like HTTP/2, QUIC uses odd-numbered StreamIDs for client initiated streams, and
even-numbered IDs for server initiated (i.e. server push) streams.  Unlike
HTTP/2 there are a couple of reserved (or dedicated) StreamIDs in QUIC.</t>

<section anchor="reserved-streams" title="Reserved Streams">

<t>StreamID 1 is reserved for crypto operations (the handshake, crypto config
updates), and MUST NOT be used for HTTP/2 headers or body, see
<xref target="QUIC-TRANSPORT"/>.  StreamID 3 is reserved for sending and receiving HTTP/2
HEADERS frames.  Therefore the first client initiated data stream has StreamID
5.</t>

<t>There are no reserved server initiated StreamIDs, so the first server initiated
(i.e. server push) stream has an ID of 2, followed by 4, etc.</t>

<section anchor="stream-3-headers" title="Stream 3: headers">

<t>HTTP/2-over-QUIC uses HPACK header compression as described in <xref target="RFC7541"/>.
HPACK was designed for HTTP/2 with the assumption of in- order delivery such as
that provided by TCP.  A sequence of encoded header blocks must arrive (and be
decoded) at an endpoint in the same order in which they were encoded.  This
ensures that the dynamic state at the two endpoints remains in sync.</t>

<t>QUIC streams provide in-order delivery of data sent on those streams, but there
are no guarantees about order of delivery between streams.  To achieve in-order
delivery of HEADERS frames in QUIC, they are all sent on the reserved Stream 3.
Data (request/response bodies) which arrive on other data streams are buffered
until the corresponding HEADERS arrive and are read out of Stream 3.</t>

<t>This does introduce head-of-line blocking: if the packet containing HEADERS for
stream N is lost or reordered then stream N+2 cannot be processed until they it
has been retransmitted successfully, even though the HEADERS for stream N+2 may
have arrived.</t>

<t>Trailing headers (trailers) can also be sent on stream 3.  These are sent as
HTTP/2 HEADERS frames, but MUST have the END_STREAM bit set, and MUST include a
“:final-offset” pseudo-header.  Since QUIC supports out of order delivery,
receipt of a HEADERS frame with the END_STREAM bit set does not guarantee that
the entire request/ response body has been fully received.  Therefore, the extra
“:final-offset” pseudo-header is included in trailing HEADERS frames to indicate
the total number of body bytes sent on the corresponding data stream.  This is
used by the QUIC layer to determine when the full request has been received and
therefore when it is safe to tear down local stream state.  The “:final-offset”
pseudo header is stripped from the HEADERS before passing to the HTTP/2 layer.</t>

</section>
<section anchor="stream-states" title="Stream states">

<t>The mapping of HTTP/2-over-QUIC with potential out of order delivery of HEADERS
frames results in some changes to the HTTP/2 stream state transition diagram
(<xref target="RFC7540"/>, Section 5.1}}.  Specifically the transition from “open” to “half
closed (remote)”, and the transition from “half closed (local)” to “closed”
takes place only when:</t>

<t><list style="symbols">
  <t>the peer has explicitly ended the stream via either  <list style="symbols">
      <t>an HTTP/2 HEADERS frame with END_STREAM bit set and, in the case of trailing
headers, the :final-offset pseudo-header</t>
      <t>or a QUIC stream frame with the FIN bit set.</t>
    </list></t>
  <t>and the full request or response body has been received.</t>
</list></t>

</section>
</section>
</section>
<section anchor="stream-priorities" title="Stream Priorities">

<t>HTTP/2-over-QUIC uses the HTTP/2 priority scheme described in <xref target="RFC7540"/>
Section 5.3.  In the HTTP/2 priority scheme, a given stream can be designated as
dependent upon another stream, which expresses the preference that the latter
stream (the “parent” stream) be allocated resources before the former stream
(the “dependent” stream).  Taken together, the dependencies across all streams
in a connection form a dependency tree.  The structure of the dependency tree
changes as HTTP/2 HEADERS and PRIORITY frames add, remove, or change the
dependency links between streams.</t>

<t>Implicit in this scheme is the notion of in-order delivery of priority changes
(i.e., dependency tree mutations): since operations on the dependency tree such
as reparenting a subtree are not commutative, both sender and receiver must
apply them in the same order to ensure that both sides have a consistent view of
the stream dependency tree.  HTTP/2 specifies priority assignments in PRIORITY
frames and (optionally) in HEADERS frames.  To achieve in-order delivery of
HTTP/2 priority changes in HTTP/2-over-QUIC, HTTP/2 PRIORITY frames, in addition
to HEADERS frames, are also sent on reserved stream 3.  The semantics of the
Stream Dependency, Weight, E flag, and (for HEADERS frames) PRIORITY flag are
the same as in HTTP/2-over-TCP.</t>

<t>Since HEADERS and PRIORITY frames are sent on a different stream than the STREAM
frames for the streams they reference, they may be delivered out-of-order with
respect to the STREAM frames.  There is no special handling for this–the
receiver should simply assign resources according to the most recent stream
priority information that it has received.</t>

<t>ALTERNATIVE DESIGN: if the core QUIC protocol implements priorities, then this
document should map the HTTP/2 priorities scheme to that provided by the core
protocol.  This would likely involve prohibiting the sending of HTTP/2 PRIORITY
frames and setting of the PRIORITY flag in HTTP/2 HEADERS frames, to avoid
conflicting directives.</t>

</section>
<section anchor="flow-control" title="Flow Control">

<t>QUIC provides stream and connection level flow control, similar in principle to
HTTP/2’s flow control but with some implementation differences.  As flow control
is handled by QUIC, the HTTP/2 mapping need not concern itself with maintaining
flow control state, or how/ when to send flow control frames to the peer.  The
HTTP/2 mapping must not send HTTP/2 WINDOW_UPDATE frames.</t>

<t>The initial flow control window sizes (stream and connection) are communicated
during the crypto handshake (see <xref target="connection-establishment"/>).  Setting these
values to the maximum size (2^31 - 1) effectively disables flow control.</t>

<t>Relatively small initial windows can be used, as QUIC will attempt to auto-tune
the flow control windows based on usage.  See <xref target="QUIC-TRANSPORT"/> for more
details.</t>

</section>
<section anchor="server-push" title="Server Push">

<t>HTTP/2-over-QUIC supports HTTP/2 server push.  During connection establishment,
the client indicates whether or it is willing to receive server pushes via the
SETTINGS_ENABLE_PUSH setting in the HTTP/2 SETTINGS frame (see
<xref target="connection-establishment"/>), which defaults to 1 (true).</t>

<t>As with server push for HTTP/2-over-TCP, the server initiates a server push by
sending an HTTP/2 PUSH_PROMISE frame containing the StreamID of the stream to be
pushed, as well as request header fields attributed to the request.  The
PUSH_PROMISE frame is sent on stream 3, to ensure proper ordering with respect
to other HEADERS and non- data frames.  Within the PUSH_PROMISE frame, the
StreamID in the common HTTP/2 frame header indicates the associated (client-
initiated) stream for the new push stream, while the Promised Stream ID field
specifies the StreamID of the new push stream.</t>

<t>The server push response is conveyed in the same way as a non-server- push
response, with response headers and (if present) trailers carried by HTTP/2
HEADERS frames sent on reserved stream 3, and response body (if any) sent via
QUIC stream frames on the stream specified in the corresponding PUSH_PROMISE
frame.</t>

</section>
<section anchor="error-codes" title="Error Codes">

<t>The HTTP/2 error codes defined in Section 7 of <xref target="RFC7540"/> map to QUIC error
codes as follows:</t>

<t><list style="hanging">
  <t hangText='NO_ERROR (0x0):'>
  Maps to QUIC_NO_ERROR</t>
  <t hangText='PROTOCOL_ERROR (0x1):'>
  No single mapping?</t>
  <t hangText='INTERNAL_ERROR (0x2)'>
  QUIC_INTERNAL_ERROR? (not currently defined in core protocol spec)</t>
  <t hangText='FLOW_CONTROL_ERROR (0x3):'>
  QUIC_FLOW_CONTROL_RECEIVED_TOO_MUCH_DATA? (not currently defined in core
protocol spec)</t>
  <t hangText='SETTINGS_TIMEOUT (0x4):'>
  (depends on whether we support SETTINGS acks)</t>
  <t hangText='STREAM_CLOSED (0x5):'>
  QUIC_STREAM_DATA_AFTER_TERMINATION</t>
  <t hangText='FRAME_SIZE_ERROR (0x6)'>
  QUIC_INVALID_FRAME_DATA</t>
  <t hangText='REFUSED_STREAM (0x7):'>
  ?</t>
  <t hangText='CANCEL (0x8):'>
  ?</t>
  <t hangText='COMPRESSION_ERROR (0x9):'>
  QUIC_DECOMPRESSION_FAILURE (not currently defined in core spec)</t>
  <t hangText='CONNECT_ERROR (0xa):'>
  ? (depends whether we decide to support CONNECT)</t>
  <t hangText='ENHANCE_YOUR_CALM (0xb):'>
  ?</t>
  <t hangText='INADEQUATE_SECURITY (0xc):'>
  QUIC_HANDSHAKE_FAILED, QUIC_CRYPTO_NO_SUPPORT</t>
  <t hangText='HTTP_1_1_REQUIRED (0xd):'>
  ?</t>
</list></t>

<t>TODO: fill in missing error code mappings.</t>

</section>
<section anchor="other-http2-frames" title="Other HTTP/2 frames">

<t>QUIC includes some features (e.g. flow control) which are also present in
HTTP/2.  In these cases the HTTP/2 mapping need not re- implement them.  As a
result some HTTP/2 frame types are not required when using QUIC, as they either
are directly implemented in the QUIC layer, or their functionality is provided
via other means.  This section of the document describes these cases.</t>

<section anchor="goaway-frame" title="GOAWAY frame">

<t>QUIC has its own GOAWAY frame, and QUIC implementations may to expose the
sending of a GOAWAY to the application.  The semantics of sending a GOAWAY in
QUIC are identical to HTTP/2: an endpoint sending a GOAWAY will continue
processing open streams, but will not accept newly created streams.</t>

<t>QUIC’s GOAWAY frame is described in detail in the <xref target="QUIC-TRANSPORT"/>.</t>

</section>
<section anchor="ping-frame" title="PING frame">

<t>QUIC has its own PING frame, which is currently exposed to the application.
QUIC clients send periodic PINGs to servers if there are no currently active
data streams on the connection.</t>

<t>QUIC’s PING frame is described in detail in the <xref target="QUIC-TRANSPORT"/>.</t>

</section>
<section anchor="padding-frame" title="PADDING frame">

<t>There is no HTTP/2 padding in this mapping; padding is instead provided at the
QUIC layer by including QUIC PADDING frames in a packet payload.  An HTTP/2 over
QUIC mapping should treat any HTTP/2 level padding as an error, to avoid any
possibility of inconsistent flow control states between endpoints (e.g. client
sends HTTP/2 padding, counts it against flow control, server ignores).</t>

</section>
</section>
<section anchor="security-considerations" title="Security Considerations">

<t>The security considerations of HTTP over QUIC should be comparable to those of
HTTP/2.</t>

</section>
<section anchor="iana-considerations" title="IANA Considerations">

<t>This document has no IANA actions.  Yet.</t>

</section>


  </middle>

  <back>

    <references title='Normative References'>

<reference anchor="QUIC-TLS" >
  <front>
    <title>Using Transport Layer Security (TLS) to Secure QUIC</title>
    <author initials="M." surname="Thomson" fullname="Martin Thomson" role="editor">
      <organization>Mozilla</organization>
    </author>
    <author initials="S." surname="Turner, Ed" fullname="Sean Turner" role="editor">
      <organization>sn3rd</organization>
    </author>
    <date />
  </front>
</reference>
<reference anchor="QUIC-TRANSPORT" >
  <front>
    <title>QUIC: A UDP-Based Multiplexed and Secure Transport</title>
    <author initials="J." surname="Iyengar" fullname="Jana Iyengar" role="editor">
      <organization>Google</organization>
    </author>
    <author initials="M." surname="Thomson" fullname="Martin Thomson" role="editor">
      <organization>Mozilla</organization>
    </author>
    <date />
  </front>
</reference>




<reference  anchor='RFC7540' target='http://www.rfc-editor.org/info/rfc7540'>
<front>
<title>Hypertext Transfer Protocol Version 2 (HTTP/2)</title>
<author initials='M.' surname='Belshe' fullname='M. Belshe'><organization /></author>
<author initials='R.' surname='Peon' fullname='R. Peon'><organization /></author>
<author initials='M.' surname='Thomson' fullname='M. Thomson' role='editor'><organization /></author>
<date year='2015' month='May' />
<abstract><t>This specification describes an optimized expression of the semantics of the Hypertext Transfer Protocol (HTTP), referred to as HTTP version 2 (HTTP/2).  HTTP/2 enables a more efficient use of network resources and a reduced perception of latency by introducing header field compression and allowing multiple concurrent exchanges on the same connection.  It also introduces unsolicited push of representations from servers to clients.</t><t>This specification is an alternative to, but does not obsolete, the HTTP/1.1 message syntax.  HTTP's existing semantics remain unchanged.</t></abstract>
</front>
<seriesInfo name='RFC' value='7540'/>
<seriesInfo name='DOI' value='10.17487/RFC7540'/>
</reference>



<reference  anchor='RFC2119' target='http://www.rfc-editor.org/info/rfc2119'>
<front>
<title>Key words for use in RFCs to Indicate Requirement Levels</title>
<author initials='S.' surname='Bradner' fullname='S. Bradner'><organization /></author>
<date year='1997' month='March' />
<abstract><t>In many standards track documents several words are used to signify the requirements in the specification.  These words are often capitalized. This document defines these words as they should be interpreted in IETF documents.  This document specifies an Internet Best Current Practices for the Internet Community, and requests discussion and suggestions for improvements.</t></abstract>
</front>
<seriesInfo name='BCP' value='14'/>
<seriesInfo name='RFC' value='2119'/>
<seriesInfo name='DOI' value='10.17487/RFC2119'/>
</reference>



<reference  anchor='RFC7541' target='http://www.rfc-editor.org/info/rfc7541'>
<front>
<title>HPACK: Header Compression for HTTP/2</title>
<author initials='R.' surname='Peon' fullname='R. Peon'><organization /></author>
<author initials='H.' surname='Ruellan' fullname='H. Ruellan'><organization /></author>
<date year='2015' month='May' />
<abstract><t>This specification defines HPACK, a compression format for efficiently representing HTTP header fields, to be used in HTTP/2.</t></abstract>
</front>
<seriesInfo name='RFC' value='7541'/>
<seriesInfo name='DOI' value='10.17487/RFC7541'/>
</reference>




    </references>



<section anchor="contributors" title="Contributors">

<t>The original authors of this specification were Robbie Shade and Mike Warres.</t>

</section>


  </back>
</rfc>

