WebSubの仕様 日本語版

PubSubHubbubの後継なのか名前が変わったのかよくわからないが、WebSubってのが新しくW3C勧告候補に昇格らしいので、とりあえずW3CのドキュメントをGoogle翻訳使いながら翻訳してみる。
[元のドキュメント（W3C）](https://www.w3.org/TR/websub/)

量が多くて大変なので、出来れば誰か手伝って欲しい...もしくは誰か翻訳してくんないかなぁ...
https://gist.github.com/tao-s/5f060640830e47971209ffcc804ff4b5

----
<h1 class="title p-name" id="title" property="dcterms:title">WebSub</h1>
<h2 id="w3c-candidate-recommendation-11-april-2017"><abbr title="World Wide Web Consortium">W3C</abbr> Candidate Recommendation <time property="dcterms:issued" class="dt-published" datetime="2017-04-11">11 April 2017</time></h2>
<dl>
      <dt>This version:</dt>
      <dd><a class="u-url" href="https://www.w3.org/TR/2017/CR-websub-20170411/">https://www.w3.org/TR/2017/CR-websub-20170411/</a></dd>
      <dt>Latest published version:</dt>
      <dd><a href="https://www.w3.org/TR/websub/">https://www.w3.org/TR/websub/</a></dd>
      <dt>Latest editor's draft:</dt>
      <dd><a href="https://w3c.github.io/websub/">https://w3c.github.io/websub/</a></dd>
      <dt>Test suite:</dt>
      <dd><a href="https://websub.rocks/">https://websub.rocks/</a></dd>
      <dt>Implementation report:</dt>
      <dd><a href="https://github.com/w3c/websub/tree/master/implementation-reports">https://github.com/w3c/websub/tree/master/implementation-reports</a></dd>
      <dt>Previous version:</dt>
      <dd><a rel="dcterms:replaces" href="https://www.w3.org/TR/2016/WD-websub-20161124/">https://www.w3.org/TR/2016/WD-websub-20161124/</a></dd>
      <dt>Editors:</dt>
      <dd class="p-author h-card vcard" property="bibo:editor" resource="_:editor0" data-editor-id="49792"><span property="rdf:first" typeof="foaf:Person"><meta property="foaf:name" content="Julien Genestoux"><a class="u-url url p-name fn" property="foaf:homepage" href="https://www.ouvre-boite.com/">Julien Genestoux</a></span>
        <span property="rdf:rest" resource="_:editor1"></span>
      </dd>
      <dd class="p-author h-card vcard" resource="_:editor1" data-editor-id="59996"><span property="rdf:first" typeof="foaf:Person"><meta property="foaf:name" content="Aaron Parecki"><a class="u-url url p-name fn" property="foaf:homepage" href="https://aaronparecki.com/">Aaron Parecki</a></span>
        <span property="rdf:rest" resource="rdf:nil"></span>
      </dd>

      <dt>Author:</dt>
      <dd class="p-author h-card vcard"><span property="dc:contributor" typeof="foaf:Person"><span property="foaf:name" class="p-name fn">Julien Genestoux</span></span>
      </dd>

      <dt>Past Authors:</dt>
      <dd>
        <a href="https://bradfitz.com/">
                      Brad Fitzpatrick
                    </a>
      </dd>
      <dd>
        <a href="http://www.onebigfluke.com/">
                      Brett Slatkin
                    </a>
      </dd>
      <dd>
        <a href="http://martin.atkins.me.uk/">
                      Martin Atkins
                    </a>
      </dd>
      <dt>Repository:</dt>
      <dd>
        <a href="https://github.com/w3c/websub">
                      Github
                    </a>
      </dd>
      <dd>
        <a href="https://github.com/w3c/websub/issues">
                      Issues
                    </a>
      </dd>
      <dd>
        <a href="https://github.com/w3c/websub/commits/master">
                      Commits
                    </a>
      </dd>
    </dl>
<p class="copyright">
      <a href="https://www.w3.org/Consortium/Legal/ipr-notice#Copyright">Copyright</a> © 2017

      <a href="https://www.w3.org/"><abbr title="World Wide Web Consortium">W3C</abbr></a><sup>®</sup> (<a href="https://www.csail.mit.edu/"><abbr title="Massachusetts Institute of Technology">MIT</abbr></a>,
      <a href="https://www.ercim.eu/"><abbr title="European Research Consortium for Informatics and Mathematics">ERCIM</abbr></a>,
      <a href="https://www.keio.ac.jp/">Keio</a>, <a href="http://ev.buaa.edu.cn/">Beihang</a>).
      <abbr title="World Wide Web Consortium">W3C</abbr> <a href="https://www.w3.org/Consortium/Legal/ipr-notice#Legal_Disclaimer">liability</a>,
      <a href="https://www.w3.org/Consortium/Legal/ipr-notice#W3C_Trademarks">trademark</a> and
      <a rel="license" href="https://www.w3.org/Consortium/Legal/copyright-documents">document use</a> rules apply.
    </p>
<section id="abstract" class="introductory" property="dc:abstract">
<h2 id="h-abstract" resource="#h-abstract"><span property="xhv:role" resource="xhv:heading">概要</span></h2>
    <p>WebSubはあらゆる種類のWebコンテンツのパブリッシャとサブスクライバー間の通信にHTTP Webフックをベースとした共通のメカニズムを提供します。 サブスクリプションリクエストは、リクエストを検証するハブを介してリレーされます。 その後、ハブは利用可能になったときに新しいコンテンツと更新されたコンテンツをサブスクライバに配信します。 WebSubは以前はPubSubHubbubとして知られていました。
</p></section>
<section id="sotd" class="introductory">
<h2 id="h-sotd" resource="#h-sotd"><span property="xhv:role" resource="xhv:heading">この文書のステータス</span></h2>
<p>
<em>このセクションでは、このドキュメントの発行時点におけるステータスについて説明します。 他のドキュメントは、このドキュメントよりも優先されます。 現在の<a href="https://www.w3.org/TR/"><abbr title="World Wide Web Consortium">W3C</abbr> technical reports index</a>の出版物のリストとこの技術レポートの最新の改訂版は、
<a href="https://www.w3.org/TR/"><abbr title="World Wide Web Consortium">W3C</abbr> technical reports index</a>テクニカルレポートのインデックスは https://www.w3.org/TR/ でご覧いただけます。</em>
</p>
<p>This document was published by the <a href="https://www.w3.org/Social/WG">Social Web Working Group</a> as a Candidate Recommendation. This document is intended to become a <abbr title="World Wide Web Consortium">W3C</abbr> Recommendation. If you wish to make comments regarding this document, please send them to<a href="mailto:public-socialweb@w3.org">public-socialweb@w3.org</a> (<a href="mailto:public-socialweb-request@w3.org?subject=subscribe">subscribe</a>,
<a href="https://lists.w3.org/Archives/Public/public-socialweb/">archives</a>).
<abbr title="World Wide Web Consortium">W3C</abbr> publishes a Candidate Recommendation to indicate that the document is believed to be stable and to encourage implementation by the developer community. This Candidate Recommendation is expected to advance to Proposed Recommendation no earlier than 11 May 2017. All comments are welcome.
</p>
<p>
Please see the Working Group's <a href="https://github.com/w3c/websub/tree/master/implementation-reports">implementation
report</a>.
</p>
<p>
Publication as a Candidate Recommendation does not imply endorsement by the <abbr title="World Wide Web Consortium">W3C</abbr> Membership. This is a draft document and may be updated, replaced or obsoleted by other documents at any time. It is inappropriate to cite this document as other than work in progress.
</p>
<p>
This document was produced by a group operating under the
<a id="sotd_patent" property="w3p:patentRules" href="https://www.w3.org/Consortium/Patent-Policy-20040205/">5 February 2004 <abbr title="World Wide Web Consortium">W3C</abbr> Patent
Policy</a>.
<abbr title="World Wide Web Consortium">W3C</abbr> maintains a <a href="https://www.w3.org/2004/01/pp-impl/72531/status" rel="disclosure">public list of any patent
disclosures</a> made in connection with the deliverables of the group; that page also includes instructions for disclosing a patent. An individual who has actual knowledge of a patent which the individual believes contains
<a href="https://www.w3.org/Consortium/Patent-Policy-20040205/#def-essential">Essential
Claim(s)</a> must disclose the information in accordance with
<a href="https://www.w3.org/Consortium/Patent-Policy-20040205/#sec-Disclosure">section
6 of the <abbr title="World Wide Web Consortium">W3C</abbr> Patent Policy</a>.
</p>
<p>This document is governed by the <a id="w3c_process_revision" href="https://www.w3.org/2017/Process-20170301/">1 March 2017 <abbr title="World Wide Web Consortium">W3C</abbr> Process Document</a>.
</p>

<section id="at-risk" typeof="bibo:Chapter" resource="#at-risk" property="bibo:hasPart">
<h3 id="h-at-risk" resource="#h-at-risk"><span property="xhv:role" resource="xhv:heading">リスクのある機能（実装間に合わんかったやつ?）</span></h3>
<p>これらの機能にはリスクがあります。; if interoperable implementations are not found, they may be removed to advance the other features in this specification to Proposed Recommendation:</p>
<ul>
<li>Host-Metaの発見方法</li>
<li>&lt;link&gt;タグの制限は、HTML文書の&lt;head&gt;に制限されています</ul>
</section>
</section>
<section typeof="bibo:Chapter" resource="" property="bibo:hasPart">

<p>
This document is currently a <abbr title="World Wide Web Consortium">W3C</abbr> TR track document. Current bugs and issues are managed in <a href="https://github.com/w3c/websub/issues">GitHub</a>.
</p>

</section>

<section id="definitions" typeof="bibo:Chapter" resource="#definitions" property="bibo:hasPart">
<!--OddPage-->
<h2 id="h-definitions" resource="#h-definitions"><span property="xhv:role" resource="xhv:heading"><span class="secno">1. </span>定義</span>
</h2>
<dl>
<dt><dfn data-dfn-type="dfn" id="dfn-topic">トピック</dfn></dt>
<dd>HTTP [<cite><a class="bibref" href="#bib-RFC7230">RFC7230</a></cite>]リソースURL。 自分が購読可能なユニット。</dd>
<dt><dfn data-dfn-type="dfn" id="dfn-hub-the-hub">ハブ ("the hub")</dfn></dt>
<dd>このプロトコルの両側を実装するサーバー（URL [<cite><a class="bibref" href="#bib-WHATWG-URL">WHATWG-URL</a></cite>]）。 どんなハブもそれを誰が使うことができるかについて独自のポリシーを実装してもよい（<em class="rfc2119" title="MAY">MAY</em>） 。</dd>
<dt><dfn data-dfn-type="dfn" id="dfn-publisher">パブリッシャー（出版者）</dfn></dt>
<dd>An owner of a topic. Notifies the hub when the topic feed has been updated. As in almost all pubsub systems, the publisher is unaware of the subscribers, if any. Other pubsub systems might call the publisher the "source".</dd>
<dt><dfn data-dfn-type="dfn" id="dfn-subscriber">サブスクライバー（購読者）</dfn></dt>
<dd>An entity (person or program) that wants to be notified of changes on a topic. The subscriber must be directly network-accessible and is identified by its Subscriber Callback URL. </dd>
<dt><dfn data-dfn-type="dfn" id="dfn-subscription">サブスクリプション（購読）</dfn></dt>
<dd>A unique relation to a topic by a subscriber that indicates it should receive updates for that topic. A subscription's unique key is the tuple (Topic URL, Subscriber Callback URL). Subscriptions may (at the hub's decision) have expiration times akin to DHCP leases which must be periodically renewed. </dd>
<dt><dfn data-dfn-type="dfn" id="dfn-subscriber-callback-url">サブスクライバー コールバック URL</dfn></dt>
<dd>The URL [<cite><a class="bibref" href="#bib-WHATWG-URL">WHATWG-URL</a></cite>] at which a subscriber wishes to receive notifications. </dd>
<dt><dfn data-dfn-type="dfn" id="dfn-event">イベント</dfn></dt>
<dd>An event that causes updates to multiple topics. For each event that happens (e.g. "Brad posted to the Linux Community."), multiple topics could be affected (e.g. "Brad posted." and "Linux community has new post"). Publisher events cause topics to be updated and the hub looks up all subscriptions for affected topics, sending out notifications to subscribers. </dd>
<dt><dfn data-dfn-type="dfn" id="dfn-notification">通知</dfn></dt>
<dd>A payload describing how a topic's contents have changed, or the full updated content. Depending on the topic's content type, the difference (or "delta") may be computed by the hub and sent to all subscribers. </dd>
</dl>
</section>

<section id="high-level-protocol-flow" typeof="bibo:Chapter" resource="#high-level-protocol-flow" property="bibo:hasPart">
<!--OddPage-->
<h2 id="h-high-level-protocol-flow" resource="#h-high-level-protocol-flow"><span property="xhv:role" resource="xhv:heading"><span class="secno">2. </span>ハイレベルプロトコルフロー</span>
</h2>
<p>(このセクションは参考（non-normative）セクションです)</p>
<ul>
<li>パブリッシャーは彼らのトピックが変更された時に彼らのハブにURLを通知します。</li>
<li>サブスクライバーは、興味を持っているトピックを、それが告知されているハブの1つ以上にPOSTします。</li>
<li>ハブは、トピックの変更を識別すると、登録されたすべてのサブスクライバに通知を送信します。</li>
</ul>
<p>このプロトコルの以前のバージョンはPubSubHubbubと呼ばれました:</p>
<ul>
<li>Working Draft 0.3 [<cite><a class="bibref" href="#bib-PubSubHubbub-Core-0.3">PubSubHubbub-Core-0.3</a></cite>]</li>
<li>Working Draft 0.4 [<cite><a class="bibref" href="#bib-PubSubHubbub-Core-0.4">PubSubHubbub-Core-0.4</a></cite>]</li>
</ul>
</section>

<section id="conformance" typeof="bibo:Chapter" resource="#conformance" property="bibo:hasPart">
<!--OddPage-->
<h2 id="h-conformance" resource="#h-conformance"><span property="xhv:role" resource="xhv:heading"><span class="secno">3. </span>準拠</span>
</h2>
<p>この文書のキーワード "<em class="rfc2119" title="MUST">MUST</em>", "<em class="rfc2119" title="MUST NOT">MUST NOT</em>", "<em class="rfc2119" title="REQUIRED">REQUIRED</em>", "<em class="rfc2119" title="SHALL">SHALL</em>", "<em class="rfc2119" title="SHALL NOT">SHALL NOT</em>", "
<em class="rfc2119" title="SHOULD">SHOULD</em>", "<em class="rfc2119" title="SHOULD NOT">SHOULD NOT</em>", "<em class="rfc2119" title="RECOMMENDED">RECOMMENDED</em>", "<em class="rfc2119" title="MAY">MAY</em>", "<em class="rfc2119" title="OPTIONAL">OPTIONAL</em>"は[<cite><a class="bibref" href="#bib-RFC2119">RFC2119</a></cite>]で説明されているように解釈される。
</p>

<section id="conformance-classes" typeof="bibo:Chapter" resource="#conformance-classes" property="bibo:hasPart">
<h3 id="h-conformance-classes" resource="#h-conformance-classes"><span property="xhv:role" resource="xhv:heading"><span class="secno">3.1 </span>準拠クラス</span>
</h3>
<p>WebSubには、パブリッシャー、サブスクライバー、ハブの3つの役割が記述されています。 このセクションでは、各ロールの適合基準について説明します。</p>
<h3 id="publishers">パブリッシャー</h3>
<ul>
<li><em class="rfc2119" title="MUST">MUST</em> 適合するパブリッシャーは、<a href="#発見">発見（Discovery）</a>で説明されている特定のリソースURLであるトピックURLとハブURLを宣言しなければならない。</li>
</ul>
<h3 id="subscribers">サブスクライバー</h3>
<p>A conforming subscriber:</p>
<ul>
<li><em class="rfc2119" title="MUST">MUST</em> support each discovery mechanism in the specified order to discover the topic and hub URLs as described in <a href="#discovery">Discovery</a>.</li>
<li><em class="rfc2119" title="MUST">MUST</em> send a subscription request as described in <a href="#subscriber-sends-subscription-request">Subscriber Sends Subscription Request</a>.</li>
<li><em class="rfc2119" title="MAY">MAY</em> request a specific lease duration</li>
<li><em class="rfc2119" title="MAY">MAY</em> include a secret in the subscription request, and if it does, then <em class="rfc2119" title="MUST">MUST</em> use the secret to verify the signature in the <a href="#authenticated-content-distribution">content distribution request</a>.</li>
<li><em class="rfc2119" title="MUST">MUST</em> acknowledge a content distribution request with an HTTP 2xx status code.</li>
<li><em class="rfc2119" title="MAY">MAY</em> request that a subscription is deactivated using the "unsubscribe" mechanism.</li>
</ul>

<h4 id="hubs">Hubs</h4>

<p>A conforming hub:</p>

<ul>
<li><em class="rfc2119" title="MUST">MUST</em> accept a subscription request with the parameters <code>hub.callback</code>, <code>hub.mode</code> and <code>hub.topic</code>.</li>
<li><em class="rfc2119" title="MUST">MUST</em> accept a subscription request with a <code>hub.secret</code> parameter.</li>
<li><em class="rfc2119" title="MAY">MAY</em> respect the requested lease duration in subscription requests.</li>
<li><em class="rfc2119" title="MUST">MUST</em> allow subscribers to re-request already active subscriptions.</li>
<li><em class="rfc2119" title="MUST">MUST</em> support unsubscription requests.</li>
<li><em class="rfc2119" title="MUST">MUST</em> send content distribution requests with a matching content type of the topic URL.</li>
<li><em class="rfc2119" title="MAY">MAY</em> reduce the payload of the content distribution to a diff of the contents for supported formats as described in <a href="#content-distribution">Content Distribution</a>.</li>
<li><em class="rfc2119" title="MUST">MUST</em> send a <code>X-Hub-Signature</code> header if the subscription was made with a <code>hub.secret</code> as described in <a href="#authenticated-content-distribution">Authenticated Content Distribution</a>.</li>
</ul>

</section>

<section id="candidate-recommendation-exit-criteria" typeof="bibo:Chapter" resource="#candidate-recommendation-exit-criteria" property="bibo:hasPart">
<h3 id="h-candidate-recommendation-exit-criteria" resource="#h-candidate-recommendation-exit-criteria"><span property="xhv:role" resource="xhv:heading"><span class="secno">3.2 </span>Candidate Recommendation Exit Criteria</span>
</h3>

<p>For this specification to exit the CR stage, there must be at least two independent, interoperable implementations of each feature. Each feature may be implemented by a different set of products. There is no requirement that all features be implemented by a single product. For the purposes of this criterion, we define the following terms:</p>

<section id="publisher" typeof="bibo:Chapter" resource="#publisher" property="bibo:hasPart">
<h4 id="h-publisher" resource="#h-publisher"><span property="xhv:role" resource="xhv:heading"><span class="secno">3.2.1 </span>Publisher</span>
</h4>
<p>A WebSub Publisher is an implementation that advertises a topic and hub URL on one or more resource URLs. The conformance criteria are described in <a href="#conformance-classes">Conformance Classes</a> above.</p>
</section>

<section id="subscriber" typeof="bibo:Chapter" resource="#subscriber" property="bibo:hasPart">
<h4 id="h-subscriber" resource="#h-subscriber"><span property="xhv:role" resource="xhv:heading"><span class="secno">3.2.2 </span>Subscriber</span>
</h4>
<p>A WebSub Subscriber is an implementation that discovers the hub and topic URL given a resouce URL, subscribes to updates at the hub, and accepts content distribution requests from the hub. The subscriber <em class="rfc2119" title="MAY">MAY</em> support <a href="#authenticated-content-distribution">authenticated content distribution</a>. The conformance criteria are described in <a href="#conformance-classes">Conformance Classes</a> above.</p>
</section>

<section id="hub" typeof="bibo:Chapter" resource="#hub" property="bibo:hasPart">
<h4 id="h-hub" resource="#h-hub"><span property="xhv:role" resource="xhv:heading"><span class="secno">3.2.3 </span>Hub</span>
</h4>
<p>A WebSub Hub is an implementation that handles subscription requests and delivers notifications to subscribers when the corresponding topic URL has been updated. Hubs <em class="rfc2119" title="MUST">MUST</em> support subscription requests with a secret and deliver <a href="#authenticated-content-distribution">authenticated notifications</a> when requested. Hubs <em class="rfc2119" title="MUST">MUST</em> deliver the full contents of the topic URL in the notification, and <em class="rfc2119" title="MAY">MAY</em> reduce the payload to a diff if the content type supports it. The conformance criteria are described in <a href="#conformance-classes">Conformance Classes</a> above.</p>
</section>

<section id="independent" typeof="bibo:Chapter" resource="#independent" property="bibo:hasPart">
<h4 id="h-independent" resource="#h-independent"><span property="xhv:role" resource="xhv:heading"><span class="secno">3.2.4 </span>Independent</span>
</h4>
<p>Each implementation must be developed by a different party and cannot share, reuse, or derive from code used by another qualifying implementation. Sections of code that have no bearing on the implementation of this specification are exempt from this requirement.</p>
</section>

<section id="interoperable" typeof="bibo:Chapter" resource="#interoperable" property="bibo:hasPart">
<h4 id="h-interoperable" resource="#h-interoperable"><span property="xhv:role" resource="xhv:heading"><span class="secno">3.2.5 </span>Interoperable</span>
</h4>
<p>A Subscriber and Hub implementation are considered interoperable for a specific feature when the Hub takes the defined action that the Subscriber requests, the Subscriber gets the expected response from a Hub according to the feature, and the Hub sends the expected response to the Subscriber.</p>
</section>

<section id="feature" typeof="bibo:Chapter" resource="#feature" property="bibo:hasPart">
<h4 id="h-feature" resource="#h-feature"><span property="xhv:role" resource="xhv:heading"><span class="secno">3.2.6 </span>Feature</span>
</h4>
<p>For the purposes of evaluating exit criteria, each of the following is considered a feature:</p>
<ul>
<li>Discovering the hub and topic URLs by looking at the HTTP headers of the resource URL.</li>
<li>Discovering the hub and topic URLs by looking at the contents of the resource URL as an XML document.</li>
<li>Discovering the hub and topic URLs by looking at the contents of the resource URL as an HTML document.</li>
<li>Discovering the hub URL by using the Host-Meta Well-Known URI.</li>
<li>Subscribing to the hub with a callback URL.</li>
<li>Subscribing to the hub and requesting a specific lease duration.</li>
<li>Subscribing to the hub with a secret and handling authenticated content distribution.</li>
<li>Requesting that a subscription is deactivated by sending an unsubscribe request.</li>
<li>The Subscriber acknowledges a pending subscription on a validation request.</li>
<li>The Subscriber rejects a subscription validation request for an invalid topic URL.</li>
<li>The Subscriber returns an HTTP 2xx response when the payload is delivered.</li>
<li>The Subscriber verifies the signature for authenticated content distribution requests.</li>
<li>The Subscriber rejects the distribution request if the signature does not validate.</li>
<li>The Subscriber rejects the distribution request when no signature is present if the subscription was made with a secret.</li>
<li>The Hub respects the requested lease duration during a subscription request.</li>
<li>The Hub allows Subscribers to re-request already active subscriptions, extending the lease duration.</li>
<li>The Hub sends the full contents of the topic URL in the distribution request.</li>
<li>The Hub sends a diff of the topic URL for the formats that support it.</li>
<li>The Hub sends a valid signature for subscriptions that were made with a secret.</li>
</ul>
</section>

</section>
</section>

<section id="discovery" typeof="bibo:Chapter" resource="#discovery" property="bibo:hasPart">
<!--OddPage-->
<h2 id="h-discovery" resource="#h-discovery"><span property="xhv:role" resource="xhv:heading"><span class="secno">4. </span>Discovery</span>
</h2>
<p>The discovery mechanism aims at identifying at least 2 URLs.</p>
<ul>
<li>The URL of the hub(s) designated by the publisher. If more than one URL is specified, it is expected that the publisher pings each of these URLs, so the subscriber may subscribe to one or more of these.</li>
<li>The canonical URL for the topic to which subscribers are expected to use for subscriptions.</li>
</ul>
<p>The protocol currently supports the following discovery mechanisms. Publishers <em class="rfc2119" title="MUST">MUST</em> implement at least one of them:</p>
<ul>
<li>Link Headers [<cite><a class="bibref" href="#bib-RFC5988">RFC5988</a></cite>]: the publisher <em class="rfc2119" title="SHOULD">SHOULD</em> include at least one Link Header [<cite><a class="bibref" href="#bib-RFC5988">RFC5988</a></cite>] with <samp>rel=hub</samp> (a hub link header) as well as exactly one Link Header [<cite><a class="bibref" href="#bib-RFC5988">RFC5988</a></cite>] with <samp>rel=self</samp> (the self link header)</li>
<li>If the topic is an XML based feed, publishers <em class="rfc2119" title="SHOULD">SHOULD</em> use embedded link elements as described in Appendix B of Web Linking [<cite><a class="bibref" href="#bib-RFC5988">RFC5988</a></cite>]. Similarly, for HTML pages, publishers <em class="rfc2119" title="SHOULD">SHOULD</em> use embedded link elements as described in Appendix A of Web Linking [<cite><a class="bibref" href="#bib-RFC5988">RFC5988</a></cite>]. However, for HTML, these <samp>&lt;link&gt;</samp> elements <em class="rfc2119" title="MUST">MUST</em> be only present in the <samp>&lt;head&gt;</samp> section of the HTML document. (Note: The restriction on limiting <samp>&lt;link&gt;</samp> to the <samp>&lt;head&gt;</samp> is At Risk.)</li>
<li>Finally, publishers <em class="rfc2119" title="MAY">MAY</em> also use the Host-Meta Well-Known URI [<cite><a class="bibref" href="#bib-RFC6415">RFC6415</a></cite>] <samp>/.well-known/host-meta</samp> to include the &lt;Link&gt; element with rel="hub". However, please note that this mechanism is currently At Risk and may be deprecated.</li>
</ul>

<div class="example">
<div class="example-title marker"><span>Example 1</span></div>
<pre class="hljs http" aria-busy="false" aria-live="polite"><span class="hljs-keyword">GET</span> <span class="hljs-string">/feed</span> HTTP/1.1
<span class="hljs-attribute">Host</span>: example.com

<span class="http">HTTP/1.1 <span class="hljs-number">200</span> Ok
<span class="hljs-attribute">Content-type</span>: text/html
<span class="hljs-attribute">Link</span>: &lt;https://hub.example.com/&gt;; rel="hub"
<span class="hljs-attribute">Link</span>: &lt;http://example.com/feed&gt;; rel="self"

<span class="xml"><span class="hljs-meta">&lt;!doctype html&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">html</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">head</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">link</span> <span class="hljs-attr">rel</span>=<span class="hljs-string">"hub"</span> <span class="hljs-attr">href</span>=<span class="hljs-string">"https://hub.example.com/"</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">link</span> <span class="hljs-attr">rel</span>=<span class="hljs-string">"self"</span> <span class="hljs-attr">href</span>=<span class="hljs-string">"http://example.com/feed"</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">head</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">body</span>&gt;</span>
...
<span class="hljs-tag">&lt;/<span class="hljs-name">body</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">html</span>&gt;</span></span></span></pre>
</div>

<p>When perfoming discovery, subscribers <em class="rfc2119" title="MUST">MUST</em> implement all three discovery mechanisms in the following order, stopping at the first match:</p>
<ol>
<li>Issue a GET or HEAD request to retrieve the topic URL. Subscribers <em class="rfc2119" title="MUST">MUST</em> check for HTTP Link headers first.</li>
<li>In the absence of HTTP Link headers, and if the topic is an XML based feed or an HTML page, subscribers <em class="rfc2119" title="MUST">MUST</em> check for embedded link elements.</li>
<li>In the absence of both HTTP Link headers and embedded link elements, subscribers <em class="rfc2119" title="MUST">MUST</em> look in the Host-Meta Well-Known URI [<cite><a class="bibref" href="#bib-RFC6415">RFC6415</a></cite>] <samp>/.well-known/host-meta</samp> for the &lt;Link&gt; element with rel="hub". However, please note that this mechanism is currently At Risk and may be deprecated.</li>
</ol>
<div class="warning">
<div class="warning-title marker"><span>Warning</span></div>
<p class="">Note: The Host-Meta method of discovery is currently At Risk and may be deprecated. The working group requests feedback on this issue, which can be <a href="https://github.com/w3c/websub/issues/97">discussed here</a>.</p>
</div>

<section id="content-negotiation" typeof="bibo:Chapter" resource="#content-negotiation" property="bibo:hasPart">
<h3 id="h-content-negotiation" resource="#h-content-negotiation"><span property="xhv:role" resource="xhv:heading"><span class="secno">4.1 </span>Content Negotiation</span>
</h3>
<p>
For practical purposes, it is important that the <samp>rel=self</samp> URL only offers a single representation. As the hub has no way of knowing what mime-type may have been requested by the subscriber upon discovery, it would not be able to perform notifications using the same mime-type.
</p>
<p>
It is, however, possible to perform content negotiation by returning an appropriate <samp>rel=self</samp> URL according to the HTTP headers used in content negotiation. For example, a request to <samp>/feed</samp> with an Accept header containing application/json could return a <samp>rel=self</samp> value of <samp>/feed.json</samp>.
</p>
<p>The example below illustrates how a topic URL can return different <samp>Link</samp> headers depending on the <samp>Accept</samp> header that was sent.</p>
<div class="example">
<div class="example-title marker"><span>Example 2</span></div>
<pre class="hljs http" aria-busy="false" aria-live="polite"><span class="hljs-keyword">GET</span> <span class="hljs-string">/feed</span> HTTP/1.1
<span class="hljs-attribute">Host</span>: example.com
<span class="hljs-attribute">Accept</span>: application/json

<span class="http">HTTP/1.1 <span class="hljs-number">200</span> Ok
<span class="hljs-attribute">Content-type</span>: application/json
<span class="hljs-attribute">Link</span>: &lt;/feed.json&gt;; rel="self"
<span class="hljs-attribute">Link</span>: &lt;https://hub.example.com/&gt;; rel="hub"

<span class="json">{
<span class="hljs-attr">"items"</span>: [...]
}</span></span></pre>
</div>
<div class="example">
<div class="example-title marker"><span>Example 3</span></div>
<pre class="hljs http" aria-busy="false" aria-live="polite"><span class="hljs-keyword">GET</span> <span class="hljs-string">/feed</span> HTTP/1.1
<span class="hljs-attribute">Host</span>: example.com
<span class="hljs-attribute">Accept</span>: text/html

<span class="http">HTTP/1.1 <span class="hljs-number">200</span> Ok
<span class="hljs-attribute">Content-type</span>: text/html
<span class="hljs-attribute">Link</span>: &lt;/feed.html&gt;; rel="self"
<span class="hljs-attribute">Link</span>: &lt;https://hub.example.com/&gt;; rel="hub"

<span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">html</span>&gt;</span>
...</span></span></pre>
</div>
</section>

</section>

<section id="subscribing-and-unsubscribing" typeof="bibo:Chapter" resource="#subscribing-and-unsubscribing" property="bibo:hasPart">
<!--OddPage-->
<h2 id="h-subscribing-and-unsubscribing" resource="#h-subscribing-and-unsubscribing"><span property="xhv:role" resource="xhv:heading"><span class="secno">5. </span>Subscribing and Unsubscribing</span>
</h2>
<p>Subscribing to a topic URL consists of four parts that may occur immediately in sequence or have a delay.</p>
<ul>
<li>Requesting a subscription using the hub </li>
<li>Validating the subscription with the publisher (<em class="rfc2119" title="OPTIONAL">OPTIONAL</em>)</li>
<li>Confirming the subscription was actually desired by the subscriber</li>
<li>Periodically reconfirming the subscription is still active (<em class="rfc2119" title="OPTIONAL">OPTIONAL</em>)</li>
</ul>
<p>Unsubscribing works in the same way, except with a single parameter changed to indicate the desire to unsubscribe. Also, the Hub will not validate unsubscription requests with the publisher.</p>

<section id="subscriber-sends-subscription-request" typeof="bibo:Chapter" resource="#subscriber-sends-subscription-request" property="bibo:hasPart">
<h3 id="h-subscriber-sends-subscription-request" resource="#h-subscriber-sends-subscription-request"><span property="xhv:role" resource="xhv:heading"><span class="secno">5.1 </span>Subscriber Sends Subscription Request</span>
</h3>
<p>Subscription is initiated by the subscriber making an HTTPS or HTTP POST [<cite><a class="bibref" href="#bib-RFC7231">RFC7231</a></cite>] request to the hub URL. This request <em class="rfc2119" title="MUST">MUST</em> have a Content-Type header of <samp>application/x-www-form-urlencoded</samp> (described in Section 4.10.22.6 [<cite><a class="bibref" href="#bib-HTML5">HTML5</a></cite>]), <em class="rfc2119" title="MUST">MUST</em> use UTF-8 [<cite><a class="bibref" href="#bib-Encoding">Encoding</a></cite>] as the document character encoding, and <em class="rfc2119" title="MUST">MUST</em> use the following parameters in its body, formatted accordingly:</p>
<dl>
<dt>hub.callback</dt>
<dd><em class="rfc2119" title="REQUIRED">REQUIRED</em>. The subscriber's callback URL where notifications should be delivered. The callback URL <em class="rfc2119" title="SHOULD">SHOULD</em> be an unguessable URL that is unique per subscription. ([<cite><a class="bibref" href="#bib-capability-urls">capability-urls</a></cite>])</dd>
<dt>hub.mode</dt>
<dd><em class="rfc2119" title="REQUIRED">REQUIRED</em>. The literal string "subscribe" or "unsubscribe", depending on the goal of the request.</dd>
<dt>hub.topic</dt>
<dd><em class="rfc2119" title="REQUIRED">REQUIRED</em>. The topic URL that the subscriber wishes to subscribe to or unsubscribe from. Note that this <em class="rfc2119" title="MUST">MUST</em> be the "self" URL found during the discovery step, which may be different from the URL that was used to make the discovery request.</dd>
<dt>hub.lease_seconds</dt>
<dd><em class="rfc2119" title="OPTIONAL">OPTIONAL</em>. Number of seconds for which the subscriber would like to have the subscription active, given as a positive decimal integer. Hubs <em class="rfc2119" title="MAY">MAY</em> choose to respect this value or not, depending on their own policies. This parameter <em class="rfc2119" title="MAY">MAY</em> be present for unsubscription requests and <em class="rfc2119" title="MUST">MUST</em> be ignored by the hub in that case.</dd>
<dt>hub.secret</dt>
<dd><em class="rfc2119" title="OPTIONAL">OPTIONAL</em>. A subscriber-provided secret string that will be used to compute an HMAC digest for <a href="#authenticated-content-distribution">authorized content distribution</a>. If not supplied, the HMAC digest will not be present for content distribution requests. This parameter <em class="rfc2119" title="SHOULD">SHOULD</em> only be specified when the request was made over HTTPS [<cite><a class="bibref" href="#bib-RFC2818">RFC2818</a></cite>]. This parameter <em class="rfc2119" title="MUST">MUST</em> be less than 200 bytes in length.</dd>
</dl>
<p>Subscribers <em class="rfc2119" title="MAY">MAY</em> also include additional HTTP [<cite><a class="bibref" href="#bib-RFC7230">RFC7230</a></cite>] request parameters, as well as HTTP [<cite><a class="bibref" href="#bib-RFC7230">RFC7230</a></cite>] Headers if they are required by the hub.</p>
<p>Hubs <em class="rfc2119" title="MUST">MUST</em> ignore additional request parameters they do not understand.</p>
<p>Hubs <em class="rfc2119" title="MUST">MUST</em> allow subscribers to re-request subscriptions that are already activated. Each subsequent request to a hub to subscribe or unsubscribe <em class="rfc2119" title="MUST">MUST</em> override the previous subscription state for a specific topic URL and callback URL combination, but only once the action is verified (<a href="#hub-verifies-intent">Section 4.3</a>). If verification fails, the subscription state <em class="rfc2119" title="MUST">MUST</em> be left unchanged. This is required so subscribers can renew their subscriptions before the lease seconds period is over without any interruption. The subscriber <em class="rfc2119" title="MAY">MAY</em> use a new hub.secret value in a future subscription, and <em class="rfc2119" title="MAY">MAY</em> make a new subscription without a hub.secret.</p>

<section id="subscription-parameter-details" typeof="bibo:Chapter" resource="#subscription-parameter-details" property="bibo:hasPart">
<h4 id="h-subscription-parameter-details" resource="#h-subscription-parameter-details"><span property="xhv:role" resource="xhv:heading"><span class="secno">5.1.1 </span>Subscription Parameter Details</span>
</h4>
<p>The topic and callback URLs <em class="rfc2119" title="MAY">MAY</em> use HTTP or HTTPS [<cite><a class="bibref" href="#bib-RFC7230">RFC7230</a></cite>] schemes. The topic URL <em class="rfc2119" title="MUST">MUST</em> be the one advertised by the publisher in a Self Link Header during the discovery phase. (See <a href="#discovery">Section 3 </a>). Hubs <em class="rfc2119" title="MAY">MAY</em> refuse subscriptions if the topic URL does not correspond to the one advertised by the publisher. The topic URL can otherwise be free-form following the URL spec [<cite><a class="bibref" href="#bib-WHATWG-URL">WHATWG-URL</a></cite>]. Hubs <em class="rfc2119" title="MUST">MUST</em> always decode non-reserved characters for these URL parameters; see section 1.2 on <em>"Percent-encoded bytes"</em> in [<cite><a class="bibref" href="#bib-WHATWG-URL">WHATWG-URL</a></cite>].</p>
<p>The callback URL <em class="rfc2119" title="SHOULD">SHOULD</em> be an unguessable unique URL ([<cite><a class="bibref" href="#bib-capability-urls">capability-urls</a></cite>]) and <em class="rfc2119" title="SHOULD">SHOULD</em> use HTTPS [<cite><a class="bibref" href="#bib-RFC7230">RFC7230</a></cite>]. The callback URL acts as authentication from the hub to the subscriber when confirming subscriptions and delivering notifications. Additionally, the callback <em class="rfc2119" title="SHOULD">SHOULD</em> be unique (not re-used for multiple hubs) and changed when subscriptions are renewed.</p>
<p>The callback URL <em class="rfc2119" title="MAY">MAY</em> contain arbitrary query string parameters (e.g., <samp>?foo=bar&amp;red=fish</samp>). Hubs <em class="rfc2119" title="MUST">MUST</em> preserve the query string during subscription verification by appending new parameters to the end of the list using the <samp>&amp;</samp> (ampersand) character to join. Existing parameters with names that overlap with those used by verification requests will not be overwritten. For event notification, the callback URL will be POSTed to including any query string parameters in the URL portion of the request, not as POST body parameters.</p>
</section>

<section id="subscription-response-details" typeof="bibo:Chapter" resource="#subscription-response-details" property="bibo:hasPart">
<h4 id="h-subscription-response-details" resource="#h-subscription-response-details"><span property="xhv:role" resource="xhv:heading"><span class="secno">5.1.2 </span>Subscription Response Details</span>
</h4>
<p>If the hub URL supports WebSub and is able to handle the subscription or unsubscription request, it <em class="rfc2119" title="MUST">MUST</em> respond to a subscription request with an HTTP [<cite><a class="bibref" href="#bib-RFC7231">RFC7231</a></cite>] 202 "Accepted" response to indicate that the request was received and will now be verified (<a href="#hub-verifies-intent">Section 4.3 </a>) and validated (<a href="#subscription-validation">Section 4.2 </a>) by the hub. The hub <em class="rfc2119" title="SHOULD">SHOULD</em> perform the verification and validation of intent as soon as possible.</p>
<p>If a hub finds any errors in the subscription request, an appropriate HTTP [<cite><a class="bibref" href="#bib-RFC7231">RFC7231</a></cite>] error response code (4xx or 5xx) <em class="rfc2119" title="MUST">MUST</em> be returned. In the event of an error, hubs <em class="rfc2119" title="SHOULD">SHOULD</em> return a description of the error in the response body as plain text, used to assist the client developer in understanding the error. This is not meant to be shown to the end user. Hubs <em class="rfc2119" title="MAY">MAY</em> decide to reject some callback URLs or topic URLs based on their own policies (e.g., domain authorization, topic URL port numbers). However, since verification and validation of intent are asynchronous steps that logically begin after the HTTP response has been returned, the HTTP response <em class="rfc2119" title="MUST NOT">MUST NOT</em> depend on the process or outcome of verification or validation.</p>
<p>If the hub URL is not able to handle subscription or unsubscription requests, it <em class="rfc2119" title="MAY">MAY</em> redirect to another hub which supports WebSub. It does so by yielding an HTTP [<cite><a class="bibref" href="#bib-RFC7231">RFC7231</a></cite>] 307 (temporary redirect) or 308 (permanent redirect) response. It <em class="rfc2119" title="MUST">MUST</em> also include at least a HTTP [<cite><a class="bibref" href="#bib-RFC7230">RFC7230</a></cite>] Location Header containing a preferred URL reference for the hub to use by the subscriber. The subscriber is expected to retry the subscription or unsubscription at the new hub URL.</p>
</section>
</section>

<section id="subscription-validation" typeof="bibo:Chapter" resource="#subscription-validation" property="bibo:hasPart">
<h3 id="h-subscription-validation" resource="#h-subscription-validation"><span property="xhv:role" resource="xhv:heading"><span class="secno">5.2 </span>Subscription Validation</span>
</h3>
<p>Subscriptions <em class="rfc2119" title="MAY">MAY</em> be validated by the Hubs who may require more details to accept or refuse a subscription. The Hub <em class="rfc2119" title="MAY">MAY</em> also check with the publisher whether the subscription should be accepted.</p>
<p>If (and when), the subscription is accepted, the hub <em class="rfc2119" title="MUST">MUST</em> perform the <a href="#hub-verifies-intent">verification of intent </a> of the subscriber.</p>
<p>If (and when), the subscription is denied, the hub <em class="rfc2119" title="MUST">MUST</em> inform the subscriber by sending an HTTP [<cite><a class="bibref" href="#bib-RFC7231">RFC7231</a></cite>] GET request to the subscriber's callback URL as given in the subscription request. This request has the following query string arguments appended (format described in Section 4 of [<cite><a class="bibref" href="#bib-WHATWG-URL">WHATWG-URL</a></cite>]):</p>
<dl>
<dt>hub.mode</dt>
<dd><em class="rfc2119" title="REQUIRED">REQUIRED</em>. The literal string "denied".</dd>
<dt>hub.topic</dt>
<dd><em class="rfc2119" title="REQUIRED">REQUIRED</em>. The topic URL given in the corresponding subscription request.</dd>
<dt>hub.reason</dt>
<dd><em class="rfc2119" title="OPTIONAL">OPTIONAL</em>. The hub may include a reason for which the subscription has been denied.</dd>
</dl>
<p>Hubs may provide an additional HTTP [<cite><a class="bibref" href="#bib-RFC7231">RFC7231</a></cite>] Location header (as described in section 7.1.2 of Hypertext Transfer Protocol [<cite><a class="bibref" href="#bib-RFC7231">RFC7231</a></cite>]) to indicate that the subscriber may retry subscribing to a different hub.topic. This allows for limited distribution to specific groups or users in the context of social web applications.</p>
<p>The subscription <em class="rfc2119" title="MAY">MAY</em> be denied by the hub at any point (even if it was previously accepted). The Subscriber <em class="rfc2119" title="SHOULD">SHOULD</em> then consider that the subscription is not possible anymore.</p>
</section>

<section id="hub-verifies-intent" typeof="bibo:Chapter" resource="#hub-verifies-intent" property="bibo:hasPart">
<h3 id="h-hub-verifies-intent" resource="#h-hub-verifies-intent"><span property="xhv:role" resource="xhv:heading"><span class="secno">5.3 </span>Hub Verifies Intent of the Subscriber</span>
</h3>
<p>In order to prevent an attacker from creating unwanted subscriptions on behalf of a subscriber (or unsubscribing desired ones), a hub must ensure that the subscriber did indeed send the subscription request.</p>
<p>The hub verifies a subscription request by sending an HTTP [<cite><a class="bibref" href="#bib-RFC7231">RFC7231</a></cite>] GET request to the subscriber's callback URL as given in the subscription request. This request has the following query string arguments appended (format described in Section 4 of [<cite><a class="bibref" href="#bib-WHATWG-URL">WHATWG-URL</a></cite>]):</p>
<dl>
<dt>hub.mode</dt>
<dd><em class="rfc2119" title="REQUIRED">REQUIRED</em>. The literal string "subscribe" or "unsubscribe", which matches the original request to the hub from the subscriber.</dd>
<dt>hub.topic</dt>
<dd><em class="rfc2119" title="REQUIRED">REQUIRED</em>. The topic URL given in the corresponding subscription request.</dd>
<dt>hub.challenge</dt>
<dd><em class="rfc2119" title="REQUIRED">REQUIRED</em>. A hub-generated, random string that <em class="rfc2119" title="MUST">MUST</em> be echoed by the subscriber to verify the subscription.</dd>
<dt>hub.lease_seconds</dt>
<dd><em class="rfc2119" title="REQUIRED">REQUIRED</em>/<em class="rfc2119" title="OPTIONAL">OPTIONAL</em>. The hub-determined number of seconds that the subscription will stay active before expiring, measured from the time the verification request was made from the hub to the subscriber. Hubs <em class="rfc2119" title="MUST">MUST</em> supply this parameter for subscription requests. This parameter <em class="rfc2119" title="MAY">MAY</em> be present for unsubscribe requests and <em class="rfc2119" title="MUST">MUST</em> be ignored by subscribers during unsubscription.</dd>
</dl>

<section id="verification-details" typeof="bibo:Chapter" resource="#verification-details" property="bibo:hasPart">
<h4 id="h-verification-details" resource="#h-verification-details"><span property="xhv:role" resource="xhv:heading"><span class="secno">5.3.1 </span>Verification Details</span>
</h4>
<p>The subscriber <em class="rfc2119" title="MUST">MUST</em> confirm that the <samp>hub.topic</samp> corresponds to a pending subscription or unsubscription that it wishes to carry out. If so, the subscriber <em class="rfc2119" title="MUST">MUST</em> respond with an HTTP success (2xx) code with a response body equal to the <samp>hub.challenge</samp> parameter. If the subscriber does not agree with the action, the subscriber <em class="rfc2119" title="MUST">MUST</em> respond with a 404 "Not Found" response.</p>
<p>The hub <em class="rfc2119" title="MUST">MUST</em> consider other server response codes (3xx, 4xx, 5xx) to mean that the verification request has failed. If the subscriber returns an HTTP [<cite><a class="bibref" href="#bib-RFC7231">RFC7231</a></cite>] success (2xx) but the content body does not match the <samp>hub.challenge</samp> parameter, the hub <em class="rfc2119" title="MUST">MUST</em> also consider verification to have failed.</p>
<p>Hubs <em class="rfc2119" title="MAY">MAY</em> make the <samp>hub.lease_seconds</samp> equal to the value the subscriber passed in their subscription request but <em class="rfc2119" title="MAY">MAY</em> change the value depending on the hub's policies. To sustain a subscription, the subscriber <em class="rfc2119" title="MUST">MUST</em> re-request the subscription on the hub before <samp>hub.lease_seconds</samp> seconds has elapsed.</p>
<p>Hubs <em class="rfc2119" title="MUST">MUST</em> enfore lease expirations, and <em class="rfc2119" title="MUST NOT">MUST NOT</em> issue perpetual lease durations.</p>
</section>
</section>
<div class="note">
<div class="note-title marker" aria-level="3" role="heading" id="h-note1"><span>Note</span></div>
<p class="">The spec uses GET vs POST to differentiate between the confirmation/denial of the subscription request and delivering the actual notification. While this is not considered "best practice" from a web architecture perspective, it does make implementation of the callback URL simpler. Since the POST body of the notification may be any arbitrary content type and only includes the actual content of the document, using the GET vs POST distinction to switch between handling these two modes makes implementations simpler.</p>
</div>
</section>

<section id="publishing" typeof="bibo:Chapter" resource="#publishing" property="bibo:hasPart">
<!--OddPage-->
<h2 id="h-publishing" resource="#h-publishing"><span property="xhv:role" resource="xhv:heading"><span class="secno">6. </span>Publishing</span>
</h2>
<p>The publisher <em class="rfc2119" title="MUST">MUST</em> inform the hubs it previously designated when a topic has been updated. The hub and the publisher can agree on any mechanism, as long as the hub is eventually able send the updated payload to the subscribers.</p>
</section>

<section id="content-distribution" typeof="bibo:Chapter" resource="#content-distribution" property="bibo:hasPart">
<!--OddPage-->
<h2 id="h-content-distribution" resource="#h-content-distribution"><span property="xhv:role" resource="xhv:heading"><span class="secno">7. </span>Content Distribution</span>
</h2>
<p>A content distribution request is sent from the Hub to the Subscriber when new content is available for a topic URL. The request is an HTTP [<cite><a class="bibref" href="#bib-RFC7231">RFC7231</a></cite>] POST request from the hub to the subscriber's callback URL. The HTTP body of the POST request <em class="rfc2119" title="MUST">MUST</em> include the payload of the notification. The content distribution request <em class="rfc2119" title="MUST">MUST</em> have a <samp>Content-Type</samp> Header corresponding to the <samp>Content-Type</samp> of the topic, and <em class="rfc2119" title="MUST">MUST</em> contain the full contents of the topic URL, with an exception allowed as described below.
</p>
<p>For Atom ([<cite><a class="bibref" href="#bib-RFC4287">RFC4287</a></cite>]) and RSS ([<cite><a class="bibref" href="#bib-RSS-2.0">RSS-2.0</a></cite>]) feeds, the hub <em class="rfc2119" title="MAY">MAY</em> remove already-delivered <code>atom:entry</code> or <code>rss:item</code> elements from the feed.
</p>
<p>The request <em class="rfc2119" title="MUST">MUST</em> include at least one Link Header [<cite><a class="bibref" href="#bib-RFC5988">RFC5988</a></cite>] with <samp>rel=hub</samp> pointing to a Hub associated with the topic being updated. It <em class="rfc2119" title="MUST">MUST</em> also include one Link Header [<cite><a class="bibref" href="#bib-RFC5988">RFC5988</a></cite>] with <samp>rel=self</samp> set to the canonical URL of the topic being updated. The Hub <em class="rfc2119" title="SHOULD">SHOULD</em> combine these headers into a single Link Header [<cite><a class="bibref" href="#bib-RFC5988">RFC5988</a></cite>]. All these URLs are those resulting from the discovery process (<a href="#discovery">Section 3</a>). The subscriber <em class="rfc2119" title="MUST NOT">MUST NOT</em> use these Link headers to identify the subscription corresponding to the content distribution request, because the Link headers are metadata associated with the topic content, not with any particular subscription. A hub <em class="rfc2119" title="MAY">MAY</em> use discovery from time to time to detect changes in a topic's canonical URL and Hub URLs. Any such changes will cause changes to the Link headers sent in subsequent content distribution requests.
</p>
<p>The successful response from the subscriber's callback URL <em class="rfc2119" title="MUST">MUST</em> be an HTTP [<cite><a class="bibref" href="#bib-RFC7231">RFC7231</a></cite>] success (2xx) code. The hub <em class="rfc2119" title="MUST">MUST</em> consider all other subscriber response codes as failures; that means subscribers <em class="rfc2119" title="MUST NOT">MUST NOT</em> use HTTP redirects for moving subscriptions. Subscribers <em class="rfc2119" title="SHOULD">SHOULD</em> respond to notifications as quickly as possible; their success response code <em class="rfc2119" title="SHOULD">SHOULD</em> only indicate receipt of the message, not acknowledgment that it was successfully processed by the subscriber. The response body from the subscriber <em class="rfc2119" title="MUST">MUST</em> be ignored by the hub. Hubs <em class="rfc2119" title="SHOULD">SHOULD</em> retry notifications up to self-imposed limits on the number of times and the overall time period to retry. When the failing delivery exceeds the hub's limits, the hub terminates the subscription.
</p>

<section id="authenticated-content-distribution" typeof="bibo:Chapter" resource="#authenticated-content-distribution" property="bibo:hasPart">
<h3 id="signing-content" resource="#signing-content"><span property="xhv:role" resource="xhv:heading"><span class="secno">7.1 </span>Authenticated Content Distribution</span>
</h3>
<p>If the subscriber supplied a value for <samp>hub.secret</samp> in their subscription request, the hub <em class="rfc2119" title="MUST">MUST</em> generate an HMAC signature of the payload and include that signature in the request headers of the content distribution request. The <samp>X-Hub-Signature</samp> header's value <em class="rfc2119" title="MUST">MUST</em> be in the form <samp>method=signature</samp> where <samp>method</samp> is one of the recognized algorithm names and <samp>signature</samp> is the, hexadecimal representation of the signature. The signature <em class="rfc2119" title="MUST">MUST</em> be computed using the HMAC algorithm [<cite><a class="bibref" href="#bib-RFC6151">RFC6151</a></cite>] with the request body as the data and the <samp>hub.secret</samp> as the key.</p>

<section id="recognized-algorithm-names" typeof="bibo:Chapter" resource="#recognized-algorithm-names" property="bibo:hasPart">
<h4 id="h-recognized-algorithm-names" resource="#h-recognized-algorithm-names"><span property="xhv:role" resource="xhv:heading"><span class="secno">7.1.1 </span>Recognized algorithm names</span>
</h4>

<p>The following algorithms are the initially registered algorithm names, based on the contents of the referenced registry at the time of publishing. [<a href="http://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.180-4.pdf">FIPS PUB 180-4</a>]</p>
<dl>
<dt>sha1</dt>
<dd>The SHA-1 algorithm as specified in Section 6.1 of [<a href="http://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.180-4.pdf">FIPS PUB 180-4</a>]</dd>
<dt>sha256</dt>
<dd>The SHA-256 algorithm as specified in Section 6.2</dd>
<dt>sha384</dt>
<dd>The SHA-384 algorithm as specified in Section 6.5</dd>
<dt>sha512</dt>
<dd>The SHA-512 algorithm as specified in Section 6.4</dd>
</dl>
<p>In the future, any algorithm added to [<a href="http://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.180-4.pdf">FIPS PUB 180-4</a>] <em class="rfc2119" title="SHOULD">SHOULD</em> be supported by hubs and subscribers.</p>
</section>

<section id="signature-validation" typeof="bibo:Chapter" resource="#signature-validation" property="bibo:hasPart">
<h4 id="h-signature-validation" resource="#h-signature-validation"><span property="xhv:role" resource="xhv:heading"><span class="secno">7.1.2 </span>Signature validation</span>
</h4>
<p>When subscribers receive a content distribution request with the<samp>X-Hub-Signature</samp> header specified, they <em class="rfc2119" title="SHOULD">SHOULD</em> recompute the signature with the shared secret using the same method (provided in the <samp>X-Hub-Signature</samp> header) as the hub. If the signature does not match, subscribers <em class="rfc2119" title="MUST">MUST</em> still return a 2xx success response to acknowledge receipt, but locally ignore the message as invalid. Using this technique along with HTTPS [<cite><a class="bibref" href="#bib-RFC2818">RFC2818</a></cite>] for subscription requests enables simple subscribers to receive authenticated notifications from hubs without the need for subscribers to run an HTTPS [<cite><a class="bibref" href="#bib-RFC2818">RFC2818</a></cite>] server.</p>
<p>Please note however that this signature only ensures that the payload was not forged. Since the notification also includes headers, these should not be considered as safe by the subscriber, unless of course the subscriber uses HTTPS [<cite><a class="bibref" href="#bib-RFC2818">RFC2818</a></cite>] callbacks.</p>
</section>
</section>
</section>

<section id="security-considerations" typeof="bibo:Chapter" resource="#security-considerations" property="bibo:hasPart">
<!--OddPage-->
<h2 id="h-security-considerations" resource="#h-security-considerations"><span property="xhv:role" resource="xhv:heading"><span class="secno">8. </span>Security Considerations</span>
</h2>
<p>Here is a summary of security considerations. It is important to note that WebSub is a server to server protocol which relies only on HTTP. It is strongly recommended to use HTTPS for all requests.</p>

<section id="discovery-1" typeof="bibo:Chapter" resource="#discovery-1" property="bibo:hasPart">
<h3 id="h-discovery-1" resource="#h-discovery-1"><span property="xhv:role" resource="xhv:heading"><span class="secno">8.1 </span>Discovery</span>
</h3>
<p>There are no specific security considerations for discovery.</p>
</section>

<section id="subscriptions" typeof="bibo:Chapter" resource="#subscriptions" property="bibo:hasPart">
<h3 id="h-subscriptions" resource="#h-subscriptions"><span property="xhv:role" resource="xhv:heading"><span class="secno">8.2 </span>Subscriptions</span>
</h3>
<p>First, subscribers <em class="rfc2119" title="SHOULD">SHOULD</em> always favor the HTTPS URL for hubs (even if the URL is advertised as HTTP). Then the subscribers <em class="rfc2119" title="SHOULD">SHOULD</em> use unique unguessable capability URLs for the callbacks, as well as make them available via HTTPS. Finally, subscribers <em class="rfc2119" title="SHOULD">SHOULD</em> use a <samp>hub.secret</samp> when subscribing to allow signature of the content distribution. Hubs <em class="rfc2119" title="SHOULD">SHOULD</em> enforce short lived <samp>hub.lease_seconds</samp> (10 days is a good default). When performing intent verification, the hub <em class="rfc2119" title="SHOULD">SHOULD</em> use a random, single use <samp>hub.challenge</samp>.</p>
</section>

<section id="distribution" typeof="bibo:Chapter" resource="#distribution" property="bibo:hasPart">
<h3 id="h-distribution" resource="#h-distribution"><span property="xhv:role" resource="xhv:heading"><span class="secno">8.3 </span>Distribution</span>
</h3>
<p>The Hub <em class="rfc2119" title="MUST">MUST</em> use the exact callback used by the subscriber (including the use of HTTPS). Hubs <em class="rfc2119" title="MUST">MUST</em> sign their requests using the <samp>hub.secret</samp> supplied by subscribers. Subscribers <em class="rfc2119" title="MUST">MUST</em> perform the same signature mechanism and <em class="rfc2119" title="MUST">MUST</em> discard notifications which failed this test.</p>
</section>

<section id="security-and-privacy-review" typeof="bibo:Chapter" resource="#security-and-privacy-review" property="bibo:hasPart">
<h3 id="h-security-and-privacy-review" resource="#h-security-and-privacy-review"><span property="xhv:role" resource="xhv:heading"><span class="secno">8.4 </span>Security and Privacy Review</span>
</h3>
<p>These questions provide an overview of security and privacy considerations for this specification as guided by Self-Review Questionnaire: Security and Privacy ([<cite><a class="bibref" href="#bib-security-privacy-questionnaire">security-privacy-questionnaire</a></cite>]).</p>

<dl>
<dt>Does this specification deal with personally-identifiable information?</dt>
<dd>The only potentially personally-identifiable information involved are topic and callback URLs.</dd>
<dt>Does this specification deal with high-value data?</dt>
<dd>No, there is no authentication or other credentials involved.</dd>
<dt>Does this specification introduce new state for an origin that persists across browsing sessions?</dt>
<dd>No.</dd>
<dt>Does this specification expose persistent, cross-origin state to the web?</dt>
<dd>The WebSub subscriber should create a resource with information about the topic to which it subscribes.</dd>
<dt>Does this specification expose any other data to an origin that it doesn't currently have access to?</dt>
<dd>No.</dd>
<dt>Does this specification enable new script execution/loading mechanisms?</dt>
<dd>No.</dd>
<dt>Does this specification allow an origin access to a user's location?</dt>
<dd>No.</dd>
<dt>Does this specification allow an origin access to sensors on a user's device?</dt>
<dd>No.</dd>
<dt>Does this specification allow an origin access to aspects of a user's local computing environment?</dt>
<dd>No.</dd>
<dt>Does this specification allow an origin access to other devices?</dt>
<dd>No.</dd>
<dt>Does this specification allow an origin some measure of control over a user agent's native UI?</dt>
<dd>No.</dd>
<dt>Does this specification expose temporary identifiers to the web?</dt>
<dd>No.</dd>
<dt>Does this specification distinguish between behavior in first-party and third-party contexts?</dt>
<dd>No.</dd>
<dt>How should this specification work in the context of a user agent's "incognito" mode?</dt>
<dd>WebSub is a server to server protocol, in which "incognito" mode does not have a meaning.</dd>
<dt>Does this specification persist data to a user's local device?</dt>
<dd>No.</dd>
<dt>Does this specification allow downgrading default security characteristics?</dt>
<dd>No.</dd>
</dl>
</section>
</section>
<section class="appendix informative" id="change-log" typeof="bibo:Chapter" resource="#change-log" property="bibo:hasPart">
<h2 id="h-change-log" resource="#h-change-log"><span property="xhv:role" resource="xhv:heading"><span class="secno">A. </span>Change Log</span>
</h2>
<p><em>This section is non-normative.</em></p>
<section id="changes-from-24-november-wd-to-this-version" typeof="bibo:Chapter" resource="#changes-from-24-november-wd-to-this-version" property="bibo:hasPart">
<h3 id="h-changes-from-24-november-wd-to-this-version" resource="#h-changes-from-24-november-wd-to-this-version"><span property="xhv:role" resource="xhv:heading"><span class="secno">A.1 </span>Changes from 24 November WD to this version</span>
</h3>
<ul>
<li>Clarified wording on supported algorithms for authenticated distribution</li>
<li>Only allow <code>&lt;link&gt;</code> tags in the HTML &lt;head&gt; element</li>
<li>Added conformance criteria and CR exit criteria</li>
<li>Added examples of discovery request and response</li>
<li>Added example of using different <code>rel=self</code> URLs to support content negotiation</li>
<li>Added a security considerations section</li>
<li>Updated references to [<cite><a class="bibref" href="#bib-WHATWG-URL">WHATWG-URL</a></cite>] instead of HTML 4</li>
<li>Replaced abstract with updated description</li>
</ul>
</section>
<section id="changes-from-20-october-fpwd-to-24-november-2016" typeof="bibo:Chapter" resource="#changes-from-20-october-fpwd-to-24-november-2016" property="bibo:hasPart">
<h3 id="h-changes-from-20-october-fpwd-to-24-november-2016" resource="#h-changes-from-20-october-fpwd-to-24-november-2016"><span property="xhv:role" resource="xhv:heading"><span class="secno">A.2 </span>Changes from 20 October FPWD to 24 November 2016</span>
</h3>
<ul>
<li>Added informative reference to previous versions of the spec, PubSubHubbub 0.3 and 0.4</li>
<li>Split discovery section into separate publisher and subscriber sections</li>
<li>Clarify that publishers can use any available discovery method, and subscribers must support all</li>
<li>Marked host-meta discovery method At Risk due to no known implementations, and fixed reference to Host Meta spec instead of the previous reference to Well-Known</li>
<li>Recommend using Capability URLs as the subscriber's callback URLs for security and authenticating the notification delivery</li>
<li>Recommend not reusing callback URLs on subscription renewals</li>
<li>Clarify that the <code>hub.topic</code> must be the <code>self</code> URL that was discovered</li>
<li>Dropped the recommendation of including the <code>From</code> header on subscription requests</li>
<li>Clarify that the hub response to subscription requests must not depend on the verification or validation</li>
<li>Hubs must enforce lease expirations</li>
<li>Clarify that the notification payload should contain the full contents of the topic URL</li>
<li>Recommend that hubs should retry failed notification delivery up to self-imposed limits</li>
<li>Clarify that future defined signature methods in FIPS PUB 180-4 are allowed</li>
<li>Added informative note about the use of GET vs POST at the callback URL</li>
<li>Renamed the spec to WebSub</li>
</ul>
</section>
</section>
<section id="references" class="appendix" typeof="bibo:Chapter" resource="#references" property="bibo:hasPart">
<!--OddPage-->
<h2 id="h-references" resource="#h-references"><span property="xhv:role" resource="xhv:heading"><span class="secno">B. </span>References</span>
</h2>
<section id="normative-references" typeof="bibo:Chapter" resource="#normative-references" property="bibo:hasPart">
<h3 id="h-normative-references" resource="#h-normative-references"><span property="xhv:role" resource="xhv:heading"><span class="secno">B.1 </span>Normative references</span>
</h3>
<dl class="bibliography" resource=""><dt id="bib-Encoding">[Encoding]</dt>
<dd><a href="https://encoding.spec.whatwg.org/" property="dc:requires"><cite>Encoding Standard</cite></a>. Anne van Kesteren. WHATWG. Living Standard. URL: <a href="https://encoding.spec.whatwg.org/" property="dc:requires">https://encoding.spec.whatwg.org/</a>
</dd><dt id="bib-HTML5">[HTML5]</dt>
<dd><a href="https://www.w3.org/TR/html5/" property="dc:requires"><cite>HTML5</cite></a>. Ian Hickson; Robin Berjon; Steve Faulkner; Travis Leithead; Erika Doyle Navara; Theresa O'Connor; Silvia Pfeiffer. W3C. 28 October 2014. W3C Recommendation. URL: <a href="https://www.w3.org/TR/html5/" property="dc:requires">https://www.w3.org/TR/html5/</a>
</dd><dt id="bib-RFC2119">[RFC2119]</dt>
<dd><a href="https://tools.ietf.org/html/rfc2119" property="dc:requires"><cite>Key words for use in RFCs to Indicate Requirement Levels</cite></a>. S. Bradner. IETF. March 1997. Best Current Practice. URL: <a href="https://tools.ietf.org/html/rfc2119" property="dc:requires">https://tools.ietf.org/html/rfc2119</a>
</dd><dt id="bib-RFC2818">[RFC2818]</dt>
<dd><a href="https://tools.ietf.org/html/rfc2818" property="dc:requires"><cite>HTTP Over TLS</cite></a>. E. Rescorla. IETF. May 2000. Informational. URL: <a href="https://tools.ietf.org/html/rfc2818" property="dc:requires">https://tools.ietf.org/html/rfc2818</a>
</dd><dt id="bib-RFC5988">[RFC5988]</dt>
<dd><a href="https://tools.ietf.org/html/rfc5988" property="dc:requires"><cite>Web Linking</cite></a>. M. Nottingham. IETF. October 2010. Proposed Standard. URL: <a href="https://tools.ietf.org/html/rfc5988" property="dc:requires">https://tools.ietf.org/html/rfc5988</a>
</dd><dt id="bib-RFC6151">[RFC6151]</dt>
<dd><a href="https://tools.ietf.org/html/rfc6151" property="dc:requires"><cite>Updated Security Considerations for the MD5 Message-Digest and the HMAC-MD5 Algorithms</cite></a>. S. Turner; L. Chen. IETF. March 2011. Informational. URL: <a href="https://tools.ietf.org/html/rfc6151" property="dc:requires">https://tools.ietf.org/html/rfc6151</a>
</dd><dt id="bib-RFC6415">[RFC6415]</dt>
<dd><a href="https://tools.ietf.org/html/rfc6415" property="dc:requires"><cite>Web Host Metadata</cite></a>. E. Hammer-Lahav, Ed.; B. Cook. IETF. October 2011. Proposed Standard. URL: <a href="https://tools.ietf.org/html/rfc6415" property="dc:requires">https://tools.ietf.org/html/rfc6415</a>
</dd><dt id="bib-RFC7230">[RFC7230]</dt>
<dd><a href="https://tools.ietf.org/html/rfc7230" property="dc:requires"><cite>Hypertext Transfer Protocol (HTTP/1.1): Message Syntax and Routing</cite></a>. R. Fielding, Ed.; J. Reschke, Ed.. IETF. June 2014. Proposed Standard. URL: <a href="https://tools.ietf.org/html/rfc7230" property="dc:requires">https://tools.ietf.org/html/rfc7230</a>
</dd><dt id="bib-RFC7231">[RFC7231]</dt>
<dd><a href="https://tools.ietf.org/html/rfc7231" property="dc:requires"><cite>Hypertext Transfer Protocol (HTTP/1.1): Semantics and Content</cite></a>. R. Fielding, Ed.; J. Reschke, Ed.. IETF. June 2014. Proposed Standard. URL: <a href="https://tools.ietf.org/html/rfc7231" property="dc:requires">https://tools.ietf.org/html/rfc7231</a>
</dd><dt id="bib-WHATWG-URL">[WHATWG-URL]</dt>
<dd><a href="https://url.spec.whatwg.org/" property="dc:requires"><cite>URL Standard</cite></a>. Anne van Kesteren. WHATWG. Living Standard. URL: <a href="https://url.spec.whatwg.org/" property="dc:requires">https://url.spec.whatwg.org/</a>
</dd>
</dl>
</section>

<section id="informative-references" typeof="bibo:Chapter" resource="#informative-references" property="bibo:hasPart">
<h3 id="h-informative-references" resource="#h-informative-references"><span property="xhv:role" resource="xhv:heading"><span class="secno">B.2 </span>Informative references</span>
</h3>
<dl class="bibliography" resource=""><dt id="bib-PubSubHubbub-Core-0.3">[PubSubHubbub-Core-0.3]</dt>
<dd><a href="https://pubsubhubbub.github.io/PubSubHubbub/pubsubhubbub-core-0.3.html" property="dc:references"><cite>PubSubHubbub Core 0.3 -- Working Draft</cite></a>. B. Fitzpatrick; B. Slatkin; M. Atkins.URL: <a href="https://pubsubhubbub.github.io/PubSubHubbub/pubsubhubbub-core-0.3.html" property="dc:references">https://pubsubhubbub.github.io/PubSubHubbub/pubsubhubbub-core-0.3.html</a>
</dd><dt id="bib-PubSubHubbub-Core-0.4">[PubSubHubbub-Core-0.4]</dt>
<dd><a href="https://pubsubhubbub.github.io/PubSubHubbub/pubsubhubbub-core-0.4.html" property="dc:references"><cite>PubSubHubbub Core 0.4 -- Working Draft</cite></a>. B. Fitzpatrick; B. Slatkin; M. Atkins; J. Genestoux.URL: <a href="https://pubsubhubbub.github.io/PubSubHubbub/pubsubhubbub-core-0.4.html" property="dc:references">https://pubsubhubbub.github.io/PubSubHubbub/pubsubhubbub-core-0.4.html</a>
</dd><dt id="bib-RFC4287">[RFC4287]</dt>
<dd><a href="https://tools.ietf.org/html/rfc4287" property="dc:references"><cite>The Atom Syndication Format</cite></a>. M. Nottingham, Ed.; R. Sayre, Ed.. IETF. December 2005. Proposed Standard. URL: <a href="https://tools.ietf.org/html/rfc4287" property="dc:references">https://tools.ietf.org/html/rfc4287</a>
</dd><dt id="bib-RSS-2.0">[RSS-2.0]</dt>
<dd><a href="http://www.rssboard.org/rss-specification" property="dc:references"><cite>RSS 2.0</cite></a>. Dave Winer. RSS Board. Stable. URL: <a href="http://www.rssboard.org/rss-specification" property="dc:references">http://www.rssboard.org/rss-specification</a>
</dd><dt id="bib-capability-urls">[capability-urls]</dt>
<dd><a href="https://www.w3.org/TR/capability-urls/" property="dc:references"><cite>Good Practices for Capability URLs</cite></a>. Jeni Tennison. W3C. 18 February 2014. W3C Working Draft. URL: <a href="https://www.w3.org/TR/capability-urls/" property="dc:references">https://www.w3.org/TR/capability-urls/</a>
</dd><dt id="bib-security-privacy-questionnaire">[security-privacy-questionnaire]</dt>
<dd><a href="https://www.w3.org/TR/security-privacy-questionnaire/" property="dc:references"><cite>Self-Review Questionnaire: Security and Privacy</cite></a>. Mike West. W3C. 10 December 2015. W3C Note. URL: <a href="https://www.w3.org/TR/security-privacy-questionnaire/" property="dc:references">https://www.w3.org/TR/security-privacy-questionnaire/</a>
</dd>
</dl>
</section>
</section>