<?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.2.0 -->

<!DOCTYPE rfc SYSTEM "rfc2629.dtd" [
<!ENTITY RFC2119 SYSTEM "https://xml2rfc.tools.ietf.org/public/rfc/bibxml/reference.RFC.2119.xml">
<!ENTITY RFC6455 SYSTEM "https://xml2rfc.tools.ietf.org/public/rfc/bibxml/reference.RFC.6455.xml">
<!ENTITY RFC7230 SYSTEM "https://xml2rfc.tools.ietf.org/public/rfc/bibxml/reference.RFC.7230.xml">
<!ENTITY RFC7231 SYSTEM "https://xml2rfc.tools.ietf.org/public/rfc/bibxml/reference.RFC.7231.xml">
<!ENTITY RFC7540 SYSTEM "https://xml2rfc.tools.ietf.org/public/rfc/bibxml/reference.RFC.7540.xml">
]>

<?rfc toc="yes"?>
<?rfc tocdepth="4"?>
<?rfc sortrefs="yes"?>
<?rfc symrefs="yes"?>

<rfc ipr="trust200902" docName="draft-mcmanus-httpbis-h2-websockets-00" category="std">

  <front>
    <title abbrev="I-D">Bootstrapping WebSockets with HTTP/2</title>

    <author initials="P." surname="McManus" fullname="Patrick McManus">
      <organization>Mozilla</organization>
      <address>
        <email>mcmanus@ducksong.com</email>
      </address>
    </author>

    <date year="2017" month="October" day="15"/>

    <area>Applications and Real Time</area>
    
    

    <abstract>


<t>This document defines a mechanism for running the WebSocket Protocol
<xref target="RFC6455"/> over a single stream of an HTTP/2 connection.</t>



    </abstract>


  </front>

  <middle>


<section anchor="introduction" title="Introduction">

<t>The Hypertext Transfer Protocol (HTTP) provides compatible resource
level semantics across different versions but it does not offer
compatibility at the connection management level. Other protocols,
such as WebSockets, that rely on connection management details of HTTP
must be updated for new versions of HTTP.</t>

<t>The WebSocket Protocol <xref target="RFC6455"/> uses the HTTP/1.1 <xref target="RFC7230"/> Upgrade
mechanism to transition a TCP connection from HTTP into a WebSocket
connection. A different approach must be taken with HTTP/2
<xref target="RFC7540"/>. Due to the multiplexing nature of HTTP/2 it does not allow
connection wide header and status codes such as the Upgrade and
Connection request headers or the 101 response code. These are all required
by the <xref target="RFC6455"/> connection establishment process.</t>

<t>A server offering both HTTP/1.1 and WebSocket services can do so from
the same instance and same port although they require separate TCP
connections. Moving a server to HTTP/2 and WebSocket services requires
a separate port and protocol stack for the sole purpose of
bootstrapping WebSockets. This is a significant administrative burden
and may not even be possible in the case of large amounts of deployed
markup pointing at the old single name and port. Being able to
bootstrap WebSockets from HTTP/2 allows one server, one port, and one
TCP connection to be shared by both protocols.</t>

<t>This document extends the HTTP/2 CONNECT method. The extension allows
the substitution of a new protocol name to connect to rather than the
external host normally used by CONNECT. The result is a tunnel on a
single HTTP/2 stream that can carry data for WebSockets (or any other
protocol) while the other streams on the connection continue to carry
HTTP/2 data.</t>

<t>Streams that have been successfully established as protocol tunnels
proceed to establish and utilize the WebSocket Protocol using the
procedure defined by <xref target="RFC6455"/> treating the stream as if were the
connection in that specification.</t>

<t>This tunneled stream will be multiplexed with other regular streams on
the connection and enjoys the normal priority, cancellation, and flow
control features of HTTP/2.</t>

</section>
<section anchor="terminology" title="Terminology">

<t>In this document, the key words “MUST”, “MUST NOT”, “REQUIRED”, “SHALL”, “SHALL NOT”,
“SHOULD”, “SHOULD NOT”, “RECOMMENDED”, “MAY”, and “OPTIONAL” are to be interpreted as
described in BCP 14, <xref target="RFC2119"/>.</t>

</section>
<section anchor="the-enableconnectprotocol-settings-parameter" title="The ENABLE_CONNECT_PROTOCOL SETTINGS Parameter">

<t>This document adds a new SETTINGS Parameter to those defined by
<xref target="RFC7540"/> Section 6.5.2.</t>

<t>The new parameter is ENABLE_CONNECT_PROTOCOL (type = 0x8). The value
of the parameter MUST be 0 or 1.</t>

<t>Upon receipt of ENABLE_CONNECT_PROTOCOL with a value of 1 a client MAY
use the Extended CONNECT definition of this document when creating new
streams. Receipt of this parameter by a server does not have any
impact.</t>

<t>A sender MUST NOT send a ENABLE_CONNECT_PROTOCOL parameter with the
value of 0 after previously sending a value of 1.</t>

<t>The use of a SETTINGS Parameter to opt-in to an otherwise incompatible
protocol change is a use of “Extending HTTP/2” defined by section 5.5
of <xref target="RFC7540"/>. If a client were to use the provisions of the extended
CONNECT method defined in this document without first receiving a
ENABLE_CONNECT_PROTOCOL parameter with the value of 1 it would be a
protocol violation.</t>

</section>
<section anchor="the-extended-connect-method" title="The Extended CONNECT Method">

<t>The CONNECT Method of <xref target="RFC7540"/> Section 8.3 is modified in
the following ways:</t>

<t><list style="symbols">
  <t>A new pseudo-header :protocol MAY be included on request HEADERS
indicating the desired protocol to be spoken on the tunnel created
by CONNECT. The pseudo-header is single valued and contains a value
from the HTTP Upgrade Token Registry defined by <xref target="RFC7230"/>.</t>
  <t>On requests bearing the :protocol pseudo-header, the :scheme and
:path pseudo-header fields SHOULD be included.</t>
  <t>On requests bearing the :protocol pseudo-header, the :authority
pseudo-header field is interpreted according to <xref target="RFC7540"/> Section
8.1.2.3 instead of <xref target="RFC7540"/> Section 8.3. In particular the server
MUST not make a new TCP connection to the host and port indicated by
the :authority.</t>
</list></t>

<t>Upon receiving a CONNECT request bearing the :protocol pseudo-header
the server establishes a tunnel to another service of the protocol
type indicated by the pseudo-header. This service may or may not be
co-located with the server.</t>

<section anchor="using-extended-connect-to-bootstrap-the-websocket-protocol" title="Using Extended CONNECT To Bootstrap The WebSocket Protocol">

<t>The pseudo-header :protocol MUST be included in the CONNECT request
and it MUST have a value of websocket to initiate a WebSocket
connection on an HTTP/2 stream.</t>

<t>Upon successfully establishing a protocol tunnel the client should
proceed with The WebSocket Protocol <xref target="RFC6455"/> using the HTTP/2
stream from the CONNECT transaction as if it were the TCP connection
in <xref target="RFC6455"/>. Negotiation of WebSocket version and sub-protocols is
done unmodified within that stream.</t>

</section>
<section anchor="example" title="Example">
<figure><artwork><![CDATA[
[[ From Client ]]                        [[ From Server ]]
 
                                         SETTINGS
                                         ENABLE_CONNECT_PROTOCOL = 1

HEADERS + END_HEADERS
:method = CONNECT
:protocol = websocket
:scheme = wss
:path = /chat
:authority = server.example.com:443

                                         HEADERS + END_HEADERS
                                         :status = 200

DATA
GET /chat HTTP/1.1
Host: server.example.com
Upgrade: websocket
Connection: Upgrade
Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ==
Origin: http://example.com
Sec-WebSocket-Protocol: chat, superchat
Sec-WebSocket-Version: 13

                                         DATA
                                         HTTP/1.1 101 Plead The Fifth
                                         Upgrade: websocket
                                         Connection: Upgrade
                                         Sec-WebSocket-Accept:
                                          s3pPLMBiTxaQ9kYGzzhZRbK+xOo=
                                         Sec-WebSocket-Protocol: chat

DATA
WebSocket Data

                                         DATA + END_STREAM
                                         WebSocket Data

DATA + END_STREAM
WebSocket Data
]]></artwork></figure>

</section>
</section>
<section anchor="design-considerations" title="Design Considerations">

<t>A more native integration with HTTP/2 is certainly possible with
larger additions to HTTP/2. This design was selected to minimize the
solution complexity while still addressing the primary concern of not
being able to run HTTP/2 and WebSockets on the same port and address.</t>

</section>
<section anchor="about-intermediaries" title="About Intermediaries">

<t>This document does not change how WebSockets interacts with HTTP
proxies. If a client wishing to speak WebSockets connects via HTTP/2
to a HTTP proxy it should continue to use a traditional (i.e. not with
a :protocol pseudo-header) CONNECT to tunnel through that proxy to the
WebSocket server via HTTP.</t>

<t>The resulting version of HTTP on that tunnel determines whether
WebSockets is initiated directly or via a modified CONNECT request
described in this document.</t>

</section>
<section anchor="security-considerations" title="Security Considerations">

<t><xref target="RFC6455"/> ensures that non WebSockets clients, especially
XMLHttpRequest based clients, cannot make a WebSocket connection. Its
primary mechanism for doing that is the use of Sec- prefixed request
headers that cannot be created by XMLHttpRequest based clients. This
specification addresses that concern in two ways:</t>

<t><list style="symbols">
  <t>The CONNECT method is prohibited from being used by XMLHttpRequest</t>
  <t>The use of a pseudo-header is something that is connection specific
and HTTP/2 does not ever allow to be created outside of the protocol stack.</t>
</list></t>

</section>
<section anchor="iana-considerations" title="IANA Considerations">

<t>This document establishes a entry for the HTTP/2 Settings Registry
that was established by <xref target="RFC7540"/> Section 11.3</t>

<t>Name: ENABLE_CONNECT_PROTOCOL</t>

<t>Code: 0x8</t>

<t>Initial Value: 0</t>

<t>Specification: This document</t>

</section>
<section anchor="acknowledgments" title="Acknowledgments">

<t>The 2017 HTTP Workshop had a very productive discussion that helped
determine the key problem and acceptable level of solution complexity.</t>

</section>


  </middle>

  <back>

    <references title='Normative References'>

&RFC2119;
&RFC6455;
&RFC7230;
&RFC7231;
&RFC7540;


    </references>




  </back>

<!-- ##markdown-source:
H4sIAItq41kAA6Vaa3PbNhb9rhn9B4z7JdlaiuXEbaoZz6z8aOKpX7WVPifT
gUhIQk0SXAC0rHTS377nXoAP+dFxdpMPoUgQuM9zz73MYDDo97z2mRqLA2O8
81aWpS4W4mc1uzbJjfJOrLRfivfT6eWr3X5PzmZW3Y7FyeCo30tNUsgc76ZW
zv0gT3JZVG6w9L6cafy7O1ipmQvbDHZ28IL0WL27M/p2MNoZjPb6vQR3Fsau
x8L5FNtbJcdiUpaZxhNtCidkkYorJTMx1bnq93Rpx8LbyvndnZ3vdiBSqcf9
nhDeJGOxVi5ep6r0y7F4Qz+dsd6quWueu3Xe+Y1jK780lrYZCHquCzy7HIqz
5Iw0oltB0UvprU5uug+MXchCf2Jpx+LMfNJZJumByqXOxiJa5d9pldw4UyyG
icnpzMLYHC/dKjr26vvD3dHou3j5zZu9vXj57e7rnfZyVF/uvaG7/d5gMBBy
Rm5LPP2eLrUTcEuVq8KLVM11oWBCkatkCSldLubGClsVBTnZL1XraHFpDexm
sn7vr7+iEJ8/C3OrLDZwWJ8pOAkOyoWZwy0xJkRiikIlpP6wFinXaZop+vWV
OCm8NVCeFgQRlXi/LpX16s6LqZWFm+OI+nTxgrZ9KUprbnUK4WGuEnaa4XSr
nKlsgo0zdasy4WDiwusEGibWOGiu59iLVIfUjsNnVnmhYQqDrQrjITpWIO7i
rjrTfi2kZ1u0mghsLBeKrchnDcUFVlgSi8V02/2eq5KlkK6TK9vYBntZ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