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

<!DOCTYPE rfc SYSTEM "rfc2629.dtd" [
]>

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

<rfc ipr="trust200902" docName="draft-benfield-http2-p2p-01" category="std">

  <front>
    <title abbrev="HTTP2-P2P">Peer-to-peer Extension to HTTP/2</title>

    <author initials="C." surname="Benfield" fullname="Cory Benfield">
      <organization></organization>
      <address>
        <email>cory@lukasa.co.uk</email>
      </address>
    </author>

    <date year="2015" month="July" day="26"/>

    <area>Applications and Real-Time Area</area>
    <workgroup>Hypertext Transfer Protocol Working Group</workgroup>
    <keyword>Internet-Draft</keyword>

    <abstract>


<t>This document introduces a negotiated extension to HTTP/2 that
turns a single HTTP/2 connection into a bi-directional
communication channel.</t>



    </abstract>


  </front>

  <middle>


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

<t>The HTTP/2 <xref target="RFC7540"/> specification provides an alternative framing layer for
the semantics of HTTP/1.1 <xref target="RFC7231"/>. This framing layer in principle allows
for both parties in a HTTP/2 session to send requests and responses. However,
the HTTP/2 specification also requires that the semantics of HTTP/1.1 be
preserved. This means that one party of the conversation is considered the
client, and one the server. Only the client may send requests, and only the
server may send responses.</t>

<t>This document introduces an extension that can be advertised by a HTTP/2
client. This extension allows both the client and the server to send requests
and responses. Essentially, this extension changes the protocol such that the
notion of ‘client’ and ‘server’ are defined on a per-stream basis, rather than
a per-connection basis.</t>

<t>The principle of this extension is similar to the Reverse HTTP
<xref target="I-D.lentczner-rhttp"/> proposal made in 2009. HTTP/2’s framing makes
this a substantially more flexible extension than Reverse HTTP by allowing the
client and server to vary on a per-stream basis, rather than affecting the
whole connection.</t>

<section anchor="notational-conventions" title="Notational Conventions">

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

</section>
</section>
<section anchor="additions" title="Additions to HTTP/2">

<t>This document introduces a new HTTP/2 setting (<xref target="RFC7540"/>, Section 11.3) and a
new HTTP/2 frame type (<xref target="RFC7540"/>, Section 11.2), to allow for a HTTP/2 client
to advertise its support for receiving server-initiated streams, and to allow a
server to advertise its support for receiving client-initiated pushed streams.</t>

<t>The setting, SETTINGS_PEER_TO_PEER, is a negotiated setting (<xref target="RFC7540"/>,
Section 5.5).</t>

<section anchor="p2p-setting" title="SETTINGS_PEER_TO_PEER Setting">

<t>The following new SETTINGS parameters (<xref target="RFC7540"/>, Section 6.5.2) are defined:</t>

<t><list style="symbols">
  <t>SETTINGS_PEER_TO_PEER (0xTBA): Informs the remote endpoint of whether the
sender supports the peer-to-peer extension to HTTP/2. A value of 1 indicates
that the peer-to-peer extension is supported. Any other value, or the absence
of this setting, indicates that the peer-to-peer extension is not supported.  <vspace blankLines='1'/>
This setting MUST NOT be emitted by the server on the HTTP/2 connection. If
the client receives this setting from the server it MUST respond with a
connection error (<xref target="RFC7540"/> Section 5.4.1) of type PROTOCOL_ERROR.</t>
</list></t>

</section>
<section anchor="client-authority-frame" title="CLIENT_AUTHORITY Frame">

<t>This document introduces the CLIENT_AUTHORITY frame. This frame MUST be emitted
by a client after it sends a value of SETTINGS_PEER_TO_PEER of 1, and MAY be
emitted by a client any time after. The purpose of this frame is to allow a
client to advertise the authority or authorities for which it is prepared to
accept requests.</t>

<t>This frame always applies to a whole connection. Therefore, the stream
identifier for CLIENT_AUTHORITY frames MUST be 0. If a server receives a
CLIENT_AUTHORITY frame whose stream identifier field is anything other than 0,
it MUST respond with a connection error (<xref target="RFC7540"/> Section 5.4.1) of type
PROTOCOL_ERROR.</t>

<section anchor="payload" title="Payload">

<t>Each CLIENT_AUTHORITY frame is made up of one or more of the following
authority segments:</t>

<figure title="Client Authority Frame Payload" anchor="client-authority-frame-fig"><artwork><![CDATA[
    +----------------------+
    | Authority Length (8) |
    +----------------------+----------------------------------+
    |                      Authority (*)                      |
    +---------------------------------------------------------+
]]></artwork></figure>

<t>Each segment begins with a one-byte field indicating the length of the
authority string the client is asserting. That field is then followed by a
single authority field. The authority MUST be sent in whatever character
encoding is going to be expected by the client on receipt of the :authority
pseudo-header field.</t>

</section>
<section anchor="semantics" title="Semantics">

<t>Generally speaking, a server or coalescing intermediary has no in-band method
of validating that a client’s authority claims are valid. Therefore, a
conforming server MUST confirm a client’s authority claims using some
out-of-band method: see <xref target="authority-validation"/> for more.</t>

<t>A client MAY send a CLIENT_AUTHORITY frame at any time after the HTTP/2
preamble is complete. Each CLIENT_AUTHORITY frame is considered to be a
complete list of authorities: therefore, a server MUST disregard all prior
CLIENT_AUTHORITY frames when a new one is received. Also, servers MUST validate
the asserted authorities for all CLIENT_AUTHORITY frames, not just the first
one.</t>

</section>
</section>
<section anchor="http-changes" title="HTTP Changes">

<t>From the perspective of other HTTP RFCs, such as RFC 7231 <xref target="RFC7231"/> and
RFC 7540 <xref target="RFC7540"/>, this extension changes whether a peer is considered a
‘client’ or a ‘server’ on a per-stream basis, instead of a per-connection
basis, based on which peer opened the stream and how they did so. If a stream
is initiated by a HEADERS frame, the peer that sent the HEADERS frame is
considered the ‘client’ for the remainder of the lifetime of that stream, while
the other peer is considered the ‘server’.</t>

<t>Otherwise, the new definition of ‘client’ and ‘server’ is preserved for the
purposes of the PUSH_PROMISE frame (<xref target="RFC7540"/>, Section 6.6). As a result,
whichever peer is considered the ‘server’ for a given stream can push other
streams to the ‘client’ peer.</t>

<t>The rest of the requirements of RFC 7231 <xref target="RFC7231"/> are preserved.</t>

</section>
<section anchor="client-behavioral-changes" title="Client Behavioral Changes">

<t>When a client emits the SETTINGS_PEER_TO_PEER setting with a value of 1, it is
informing the server that it is willing to accept HTTP requests from the
server, allowing the server to open streams with HEADERS frames. This lifts
some of the restrictions of RFC 7540 <xref target="RFC7540"/> Section 8.</t>

<t>If a client has sent the SETTINGS_PEER_TO_PEER setting with a value of 1, the
client MUST NOT reject an attempt by the server to change the value of
SETTINGS_ENABLE_PUSH to 1.</t>

<t>If the client, subsequent to sending SETTINGS_PEER_TO_PEER with value 1,
receives from the server a value of SETTINGS_ENABLE_PUSH of 1, it MAY open
streams by sending PUSH_PROMISE frames. The client MUST NOT send a
PUSH_PROMISE frame on a stream that it opened by means of a HEADERS frame: only
server-initiated streams may be used for sending PUSH_PROMISE frames. All other
limitations about PUSH_PROMISE frames in RFC 7540 <xref target="RFC7540"/> continue to
apply, except that the words ‘server’ and ‘client’ are defined on a per-stream
basis.</t>

</section>
<section anchor="server-behavioral-changes" title="Server Behavioral Changes">

<t>When a server receives the SETTINGS_PEER_TO_PEER setting from the client with
a value of 1, it MAY at any point afterwards issue a non-zero value for
SETTINGS_ENABLE_PUSH. This allows clients to open streams with PUSH_PROMISE
and also lifts some of the restrictions of RFC 7540 <xref target="RFC7540"/> Section 8:
specifically those sections that only allow servers to send PUSH_PROMISE
frames, and only allow clients to receive them.</t>

<t>If the client attempts to send a PUSH_PROMISE frame on a stream that was opened
by the client (by sending a HEADERS frame), the server MUST treat this event as
a connection error (<xref target="RFC7540"/> Section 5.4.1) of type PROTOCOL_ERROR.</t>

</section>
<section anchor="other-extensions" title="Other Extensions">

<t>When this extension is deployed with other extensions to HTTP/2, the behaviour
of this extension does not change. All other extensions that refer to ‘client’
or ‘server’ SHOULD be treated as though those terms apply on a per-stream
basis.</t>

<t>If other extensions apply ‘server’ or ‘client’ to the whole connection (e.g.
for settings in SETTINGS frames, which are sent on stream 0), then both peers
SHOULD be considered clients and both peers should be considered servers.</t>

</section>
</section>
<section anchor="authority-validation" title="Authority Validation">

<t>Generally speaking, a server or coalescing intermediary has no in-band method
of validating that a client’s authority claims are valid. Therefore, a
conforming server MUST confirm a client’s authority claims using some
out-of-band method.</t>

<t>This specification does not lay out in detail any proposed mechanism for doing
this validation, as the best approach may vary from deployment to deployment.
However, some options include:</t>

<t><list style="symbols">
  <t>validating authorities against a TLS certificate presented by the client
during TLS handshake.</t>
  <t>confirming that a reverse DNS lookup for the client IP returns the authority
asserted by the client.</t>
  <t>a static list of IP addresses trusted for a given authority.</t>
</list></t>

<t>The only requirement is that a server MUST implement some form of validation,
and then MUST treat any attempt by a client to assert an authority that it
cannot validate as a connection error (<xref target="RFC7540"/> Section 5.4.1) of type
PROTOCOL_ERROR.</t>

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

<section anchor="http2-frame-type-registry-update" title="HTTP/2 Frame Type Registry Update">

<t>This document updates the HTTP/2 Frame Type registry (<xref target="RFC7540"/>, Section
11.2).  The entries in the following table are registered by this document.</t>

<texttable>
      <ttcol align='left'>Name</ttcol>
      <ttcol align='left'>Code</ttcol>
      <ttcol align='left'>Section</ttcol>
      <c>CLIENT_AUTHORITY</c>
      <c>TBD</c>
      <c><xref target="client-authority-frame"/></c>
</texttable>

</section>
<section anchor="http2-settings-registry-update" title="HTTP/2 Settings Registry Update">

<t>This document updates the registry for HTTP/2 Settings (<xref target="RFC7540"/>, Section
11.4). The entries in the following table are registered by this document.</t>

<texttable>
      <ttcol align='left'>Name</ttcol>
      <ttcol align='left'>Code</ttcol>
      <ttcol align='left'>Initial Value</ttcol>
      <ttcol align='left'>Section</ttcol>
      <c>PEER_TO_PEER</c>
      <c>TBD</c>
      <c>0</c>
      <c><xref target="p2p-setting"/></c>
</texttable>

</section>
</section>
<section anchor="acknowledgements" title="Acknowledgements">

<t>Thanks to Fedor Indutny for the original idea, and Amos Jeffries, Mike Bishop,
and Ilari Liusvaara for their follow-up.</t>

<t>Thanks also to Tyrel Souza, Donald Stufft, and Paul Kehrer for proofreading.</t>

<t>Thanks to David Reid for pointing out the Reverse HTTP proposal
<xref target="I-D.lentczner-rhttp"/>.</t>

<t>Thanks to Amos Jeffries for proposing an advertised extension, rather than a
negotiated one.</t>

</section>


  </middle>

  <back>

    <references title='Normative References'>





<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='RFC7231' target='http://www.rfc-editor.org/info/rfc7231'>
<front>
<title>Hypertext Transfer Protocol (HTTP/1.1): Semantics and Content</title>
<author initials='R.' surname='Fielding' fullname='R. Fielding' role='editor'><organization /></author>
<author initials='J.' surname='Reschke' fullname='J. Reschke' role='editor'><organization /></author>
<date year='2014' month='June' />
<abstract><t>The Hypertext Transfer Protocol (HTTP) is a stateless \%application- level protocol for distributed, collaborative, hypertext information systems.  This document defines the semantics of HTTP/1.1 messages, as expressed by request methods, request header fields, response status codes, and response header fields, along with the payload of messages (metadata and body content) and mechanisms for content negotiation.</t></abstract>
</front>
<seriesInfo name='RFC' value='7231'/>
<seriesInfo name='DOI' value='10.17487/RFC7231'/>
</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>




    </references>

    <references title='Informative References'>





<reference anchor='I-D.lentczner-rhttp'>
<front>
<title>Reverse HTTP</title>

<author initials='M' surname='Lentczner' fullname='Mark Lentczner'>
    <organization />
</author>

<author initials='D' surname='Preston' fullname='Donovan Preston'>
    <organization />
</author>

<date month='March' day='4' year='2009' />

<abstract><t>This memo explains a method for making HTTP requests to a host that cannot be contacted directly.  Typically, such a host is behind a firewall and/or a network address translation system.</t></abstract>

</front>

<seriesInfo name='Internet-Draft' value='draft-lentczner-rhttp-00' />
<format type='TXT'
        target='http://www.ietf.org/internet-drafts/draft-lentczner-rhttp-00.txt' />
</reference>




    </references>


<section anchor="changelog" title="Changelog">

<t>(This appendix to be deleted by the RFC Editor.)</t>

<t>Since -00:</t>

<t><list style="symbols">
  <t>Clarified the semantics behind multiple CLIENT_AUTHORITY frames.</t>
  <t>Removed the requirement for servers to issue SETTINGS_PEER_TO_PEER, instead
allowing the extension to be purely client-advertised.</t>
</list></t>

</section>


  </back>
</rfc>

