-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpubsubhubbub-core-0.4.html
1141 lines (1077 loc) · 65.7 KB
/
pubsubhubbub-core-0.4.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="en"><head><title>Draft: PubSubHubbub Core 0.4 -- Working Draft</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="description" content="PubSubHubbub Core 0.4 -- Working Draft">
<meta name="generator" content="xml2rfc v1.35 (http://xml.resource.org/)">
<style type='text/css'><!--
body {
font-family: verdana, charcoal, helvetica, arial, sans-serif;
font-size: small; color: #000; background-color: #FFF;
margin: 2em;
}
h1, h2, h3, h4, h5, h6 {
font-family: helvetica, monaco, "MS Sans Serif", arial, sans-serif;
font-weight: bold; font-style: normal;
}
h1 { color: #900; background-color: transparent; text-align: right; }
h3 { color: #333; background-color: transparent; }
td.RFCbug {
font-size: x-small; text-decoration: none;
width: 30px; height: 30px; padding-top: 2px;
text-align: justify; vertical-align: middle;
background-color: #000;
}
td.RFCbug span.RFC {
font-family: monaco, charcoal, geneva, "MS Sans Serif", helvetica, verdana, sans-serif;
font-weight: bold; color: #666;
}
td.RFCbug span.hotText {
font-family: charcoal, monaco, geneva, "MS Sans Serif", helvetica, verdana, sans-serif;
font-weight: normal; text-align: center; color: #FFF;
}
table.TOCbug { width: 30px; height: 15px; }
td.TOCbug {
text-align: center; width: 30px; height: 15px;
color: #FFF; background-color: #900;
}
td.TOCbug a {
font-family: monaco, charcoal, geneva, "MS Sans Serif", helvetica, sans-serif;
font-weight: bold; font-size: x-small; text-decoration: none;
color: #FFF; background-color: transparent;
}
td.header {
font-family: arial, helvetica, sans-serif; font-size: x-small;
vertical-align: top; width: 33%;
color: #FFF; background-color: #666;
}
td.author { font-weight: bold; font-size: x-small; margin-left: 4em; }
td.author-text { font-size: x-small; }
/* info code from SantaKlauss at http://www.madaboutstyle.com/tooltip2.html */
a.info {
/* This is the key. */
position: relative;
z-index: 24;
text-decoration: none;
}
a.info:hover {
z-index: 25;
color: #FFF; background-color: #900;
}
a.info span { display: none; }
a.info:hover span.info {
/* The span will display just on :hover state. */
display: block;
position: absolute;
font-size: smaller;
top: 2em; left: -5em; width: 15em;
padding: 2px; border: 1px solid #333;
color: #900; background-color: #EEE;
text-align: left;
}
a { font-weight: bold; }
a:link { color: #900; background-color: transparent; }
a:visited { color: #633; background-color: transparent; }
a:active { color: #633; background-color: transparent; }
p { margin-left: 2em; margin-right: 2em; }
p.copyright { font-size: x-small; }
p.toc { font-size: small; font-weight: bold; margin-left: 3em; }
table.toc { margin: 0 0 0 3em; padding: 0; border: 0; vertical-align: text-top; }
td.toc { font-size: small; font-weight: bold; vertical-align: text-top; }
ol.text { margin-left: 2em; margin-right: 2em; }
ul.text { margin-left: 2em; margin-right: 2em; }
li { margin-left: 3em; }
/* RFC-2629 <spanx>s and <artwork>s. */
em { font-style: italic; }
strong { font-weight: bold; }
dfn { font-weight: bold; font-style: normal; }
cite { font-weight: normal; font-style: normal; }
tt { color: #036; }
tt, pre, pre dfn, pre em, pre cite, pre span {
font-family: "Courier New", Courier, monospace; font-size: small;
}
pre {
text-align: left; padding: 4px;
color: #000; background-color: #CCC;
}
pre dfn { color: #900; }
pre em { color: #66F; background-color: #FFC; font-weight: normal; }
pre .key { color: #33C; font-weight: bold; }
pre .id { color: #900; }
pre .str { color: #000; background-color: #CFF; }
pre .val { color: #066; }
pre .rep { color: #909; }
pre .oth { color: #000; background-color: #FCF; }
pre .err { background-color: #FCC; }
/* RFC-2629 <texttable>s. */
table.all, table.full, table.headers, table.none {
font-size: small; text-align: center; border-width: 2px;
vertical-align: top; border-collapse: collapse;
}
table.all, table.full { border-style: solid; border-color: black; }
table.headers, table.none { border-style: none; }
th {
font-weight: bold; border-color: black;
border-width: 2px 2px 3px 2px;
}
table.all th, table.full th { border-style: solid; }
table.headers th { border-style: none none solid none; }
table.none th { border-style: none; }
table.all td {
border-style: solid; border-color: #333;
border-width: 1px 2px;
}
table.full td, table.headers td, table.none td { border-style: none; }
hr { height: 1px; }
hr.insert {
width: 80%; border-style: none; border-width: 0;
color: #CCC; background-color: #CCC;
}
--></style>
</head>
<body>
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc"> TOC </a></td></tr></table>
<table summary="layout" width="66%" border="0" cellpadding="0" cellspacing="0"><tr><td><table summary="layout" width="100%" border="0" cellpadding="2" cellspacing="1">
<tr><td class="header">Draft</td><td class="header">B. Fitzpatrick</td></tr>
<tr><td class="header"> </td><td class="header">B. Slatkin</td></tr>
<tr><td class="header"> </td><td class="header">Google, Inc</td></tr>
<tr><td class="header"> </td><td class="header">M. Atkins</td></tr>
<tr><td class="header"> </td><td class="header">Six Apart Ltd.</td></tr>
<tr><td class="header"> </td><td class="header">M. Keller</td></tr>
<tr><td class="header"> </td><td class="header">Facebook Inc.</td></tr>
<tr><td class="header"> </td><td class="header">June 24, 2010</td></tr>
</table></td></tr></table>
<h1><br />PubSubHubbub Core 0.4 -- Working Draft</h1>
<h3>Abstract</h3>
<p>An open, simple, web-scale pubsub protocol, along with an open source
reference implementation targeting Google App Engine. Notably, however,
nothing in the protocol is centralized, or Google- or App
Engine-specific. Anybody can play.
</p>
<p>As opposed to more developed (and more complex) pubsub specs like
<a class='info' href='#XEP-0060'>Jabber Publish-Subscribe<span> (</span><span class='info'>Millard, P., Saint-Andre, P., and R. Meijer, “Publish-Subscribe,” .</span><span>)</span></a> [XEP‑0060] this spec's base
profile (the barrier-to-entry to speak it) is dead simple. The fancy
bits required for high-volume publishers and subscribers are optional.
The base profile is HTTP-based, as opposed to XMPP (see more on this
below).
</p>
<p>In version 0.4 we have generalized the specification to support
subscription to any resource with a URL.
This was done to provide real-time notifications of changes to resources.
In addition, notifications now support specifying the type of operation
needed to reflect the synchronization change such as append, replace
or delete. This is done by having the hub more granularly convey the response from
the publisher for the resource.
Also in version 0.4 we are adding support for authenticated subscriptions
and an arbitrarily formatted payload so that for example, simple JSON
endpoints can continue using the same format.
</p>
<p>We offer this spec in hopes that it allows secure synchronization
of independent repositories of data in realtime to make the web more
open, relevant and connected.
</p><a name="toc"></a><br /><hr />
<h3>Table of Contents</h3>
<p class="toc">
<a href="#anchor1">1.</a>
Notation and Conventions<br />
<a href="#anchor2">2.</a>
Definitions<br />
<a href="#anchor3">3.</a>
High-level protocol flow<br />
<a href="#anchor4">4.</a>
Notification Details<br />
<a href="#discovery">5.</a>
Discovery<br />
<a href="#subscribing">6.</a>
Subscribing and Unsubscribing<br />
<a href="#anchor5">6.1.</a>
Subscriber Sends Subscription Request<br />
<a href="#verifysub">6.2.</a>
Hub Verifies Intent of the Subscriber<br />
<a href="#autorefresh">6.3.</a>
Automatic Subscription Refreshing<br />
<a href="#publishing">7.</a>
Publishing<br />
<a href="#anchor9">7.1.</a>
New Content Notification<br />
<a href="#contentfetch">7.2.</a>
Content Fetch<br />
<a href="#contentdistribution">7.3.</a>
Content Distribution<br />
<a href="#authednotify">7.4.</a>
Authenticated Content Distribution<br />
<a href="#aggregatedistribution">7.5.</a>
Aggregated Content Distribution<br />
<a href="#bestpractices">8.</a>
Best Practices<br />
<a href="#hubbestpractices">8.1.</a>
For Hubs<br />
<a href="#subbestpractices">8.2.</a>
For Subscribers<br />
<a href="#rfc.references1">9.</a>
References<br />
<a href="#anchor11">Appendix A.</a>
Specification Feedback<br />
<a href="#rfc.authors">§</a>
Authors' Addresses<br />
</p>
<br clear="all" />
<a name="anchor1"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc"> TOC </a></td></tr></table>
<a name="rfc.section.1"></a><h3>1.
Notation and Conventions</h3>
<p>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 <a class='info' href='#RFC2119'>[RFC2119]<span> (</span><span class='info'>Bradner, B., “Key words for use in RFCs to Indicate Requirement Levels,” .</span><span>)</span></a>. Domain name examples use <a class='info' href='#RFC2606'>[RFC2606]<span> (</span><span class='info'>Eastlake, D. and A. Panitz, “Reserved Top Level DNS Names,” .</span><span>)</span></a>.
</p>
<a name="anchor2"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc"> TOC </a></td></tr></table>
<a name="rfc.section.2"></a><h3>2.
Definitions</h3>
<p></p>
<blockquote class="text"><dl>
<dt>Topic:</dt>
<dd>A public or protected resource URL. The unit
to which one can subscribe to changes. Topics can point to resources with any Content Type.
</dd>
<dt>Feed:</dt>
<dd>A resource which is a list of items with unique
identifiers, and last modified timestamp for each item. Feeds MAY
contain the location of the hub.
Whether a resource is a Feed and where the hub is located will be determined
based on the Content-Type header.
RSS(application/rss+xml), Atom(application/atom+xml) and
JSON Activity Streams(application/stream+json) are examples of Feeds.
</dd>
<dt>Hub ("the hub"):</dt>
<dd>The server (<a class='info' href='#RFC3986'>URL<span> (</span><span class='info'>Berners-Lee, T., “Uniform Resource Identifiers (URI): Generic Syntax,” .</span><span>)</span></a> [RFC3986]) which implements both sides of this
protocol. We have implemented this and are running a server at <a href='http://pubsubhubbub.appspot.com/'>http://pubsubhubbub.appspot.com</a> that is, at least for now,
open to anybody for use, as either a publisher or subscriber. Any
hub MAY implement its own policies on who can use it.
</dd>
<dt>Publisher:</dt>
<dd>An owner of a resource. Notifies the hub
when the resource has been updated. It just notifies that it <em>has</em> been updated, but not how. 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>Subscriber:</dt>
<dd>An entity (person or program) that wants
to be notified of changes on a resource. The subscriber must be
directly network-accessible and is identified by its Subscriber
Callback URL.
</dd>
<dt>Subscription:</dt>
<dd>A unique relation to a resource 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>Subscriber Callback URL:</dt>
<dd>The <a class='info' href='#RFC3986'>URL<span> (</span><span class='info'>Berners-Lee, T., “Uniform Resource Identifiers (URI): Generic Syntax,” .</span><span>)</span></a> [RFC3986] at which a subscriber wishes to receive
notifications.
</dd>
<dt>Event:</dt>
<dd>An event that causes updates to potentially 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>Notification:</dt>
<dd>A payload describing how a topic's
contents have changed. This difference (or "delta") is computed by
the hub and sent to all subscribers if and only if the topic is a Feed.
The hub will only send the entries which are new or have changed.
If the topic is not a Feed then it cannot be used to compute deltas and
the notification will contain the entire resource as if it was fetched directly
using the topic url.
The notification can be the result of a publisher telling
the hub of an update, or the hub proactively polling a topic feed,
perhaps for a subscriber subscribing to a topic that's not
pubsub-aware. Note also that a notification to a subscriber can be a
payload consisting of updates for multiple resources. Hubs MAY
choose to send multi-resource notifications as an optimization for
heavy subscribers, but subscribers MUST understand them. See <a class='info' href='#contentdistribution'>Section 7.3<span> (</span><span class='info'>Content Distribution</span><span>)</span></a> for format details.
</dd>
</dl></blockquote>
<a name="anchor3"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc"> TOC </a></td></tr></table>
<a name="rfc.section.3"></a><h3>3.
High-level protocol flow</h3>
<p>(This section is non-normative.)
</p>
<p></p>
<ul class="text">
<li>Publishers POST a ping to their hub(s) URLs when their resource(s)
change.
</li>
<li>Subscribers POST to one or more of the advertised hubs for a
resource they're interested in. Alternatively, some hubs may offer
auto-polling capability, to let {their,any} subscribers subscribe to
topics which don't advertise a hub.
</li>
<li>The hub caches minimal metadata (id, data, entry digest) about
each resource's previous state. When the hub re-fetches a resource
(on its own initiative or as a result of a publisher's ping) and
finds a delta, it enqueues a notification to all registered
subscribers.
</li>
</ul>
<a name="anchor4"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc"> TOC </a></td></tr></table>
<a name="rfc.section.4"></a><h3>4.
Notification Details</h3>
<p>If the publisher's resources are feeds, then they should select a hub which
supports their Feed Content Type. The well known Feed Content Types are: <a class='info' href='#RFC4287'>Atom<span> (</span><span class='info'>Nottingham, M., Ed. and R. Sayre, Ed., “The Atom Syndication Format,” .</span><span>)</span></a> [RFC4287] or <a class='info' href='#RSS20'>RSS<span> (</span><span class='info'>Winer, D., “RSS 2.0,” .</span><span>)</span></a> [RSS20] or
<a class='info' href='#JSON_Activity_Stream'>JSON Activity Stream<span> (</span><span class='info'>, “JSON Activity Stream (Draft),” .</span><span>)</span></a> [JSON_Activity_Stream].
The Publisher makes the decision as to include full body, truncated body, or
meta data of most recent event(s). One of:
</p>
<p></p>
<ul class="text">
<li>URL + metadata
</li>
<li>URL + metadata + truncated
</li>
<li>URL + metadata + full
</li>
</ul>
<p>The trade-off between including all content in outgoing notifications
or having the thundering herd (by clients who fetch the <tt>//atom:feed/entry/link</tt> in response to a
notification) is up to the publisher. Entries of the most recent events
(for recipient to know whether or not they'd missed any recent items--
like TCP SACK) MAY be provided as context. Some examples of Atom feed
entries follow.
</p>
<p>Publishers with content that cannot be syndicated publicly SHOULD
utilize a hub which understands their authorization scheme. Typically these hubs are
Service Providers which support manual publishing by users specifying the privacy of their content.
These specialized hubs will require an authenticated and full
notification of changes. The mechanics of how this is done are outside
the scope of this spec.
They may be done via an <a class='info' href='#OAuth_2_0'>OAuth 2.0<span> (</span><span class='info'>, “OAuth 2.0 Protocol (Draft),” .</span><span>)</span></a> [OAuth_2_0] POST
request to the appropriate resource end point or via the user interface
if the publisher does not wish to have their own copy of the data.
</p>
<a name="discovery"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc"> TOC </a></td></tr></table>
<a name="rfc.section.5"></a><h3>5.
Discovery</h3>
<p>A potential subscriber initiates discovery by retrieving the resource to
which it wants to subscribe. The <a class='info' href='#RFC2616'>HTTP<span> (</span><span class='info'>Fielding, R., Gettys, J., Mogul, J., Frystyk, H., Masinter, L., Leach, P., and T. Berners-Lee, “Hypertext Transfer Protocol -- HTTP/1.1,” .</span><span>)</span></a> [RFC2616] response
from the publisher MUST include the location of the hub if one is available.
The location of the hub MAY be transmitted using <a class='info' href='#draft-nottingham-http-link-header-10'>Web Linking<span> (</span><span class='info'>, “Web Linking (Draft),” .</span><span>)</span></a> [draft‑nottingham‑http‑link‑header‑10]
<p>Example using HTTP headers to syndicate the hub for resource "http://www.asite.net/ciberch"
</p>
<div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
GET /ciberch HTTP/1.1
Host: www.asite.net
-------------------------------------------------------------
HTTP/1.1 200 OK
Content-Type: application/json
Link:<http://hub.company.com/>;rel="hub"
Date: Fri, 14 May 2010 20:54:17 GMT
Content-Length: 268
{
"id" : 1212121,
"type" : "user",
"about" : "sample about this can be any payload",
"name" : "Sample User",
"interests" : ["tennis", "ping-pong"]
}
</pre></div>
or inside the document if the mime type supports including a hub. Examples of this
are Atom or RSS where the hub is transmitted as a child of <tt>//atom:feed</tt>
or <tt>//rss:rss/channel</tt> an <tt>atom:link</tt> element whose <tt>rel</tt>
attribute has the value <tt>hub</tt> and whose <tt>href</tt> attribute contains the hub's endpoint URL.
<p>Feeds MAY contain multiple <tt>atom:link[@rel="hub"]</tt>
elements if the publisher wishes to notify multiple hubs. When a
potential subscriber encounters one or more such links, that subscriber
MAY subscribe to the feed using one or more hubs URLs as described in
<a class='info' href='#subscribing'>Section 6<span> (</span><span class='info'>Subscribing and Unsubscribing</span><span>)</span></a>.
</p>
<p>Example using the response body:
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
GET /topic.xml HTTP/1.1
Host: publisher.example.com
-------------------------------------------------------------
HTTP/1.1 200 OK
Content-Type: application/atom+xml; charset=utf-8
Date: Fri, 14 May 2010 20:54:17 GMT
Content-Length: 768
<?xml version="1.0"?>
<atom:feed>
<!-- Normally here would be source, title, author, id, etc ... -->
<link rel="hub" href="https://www.nicehub.com/pshb_endpoint" />
<link rel="self" href="http://publisher.example.com/topic.xml" />
....
<entry>
....
</entry>
<entry>
....
</entry>
</atom:feed>
</pre></div>
<p>Hubs MUST use the same URL for both the publishing and subscribing
interfaces, which is why only a single <tt>atom:link</tt>
element is required to declare a hub. Publishers SHOULD use <a class='info' href='#RFC2616'>HTTPS<span> (</span><span class='info'>Fielding, R., Gettys, J., Mogul, J., Frystyk, H., Masinter, L., Leach, P., and T. Berners-Lee, “Hypertext Transfer Protocol -- HTTP/1.1,” .</span><span>)</span></a> [RFC2616] in their hubs' discovery URLs. However,
subscribers that do not support <a class='info' href='#RFC2818'>HTTPS<span> (</span><span class='info'>Rescorla, E., “HTTP Over TLS,” May 2000.</span><span>)</span></a> [RFC2818] MAY
try to fallback to <a class='info' href='#RFC2616'>HTTP<span> (</span><span class='info'>Fielding, R., Gettys, J., Mogul, J., Frystyk, H., Masinter, L., Leach, P., and T. Berners-Lee, “Hypertext Transfer Protocol -- HTTP/1.1,” .</span><span>)</span></a> [RFC2616], which MAY work
depending on the hub's policy.
</p>
<a name="subscribing"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc"> TOC </a></td></tr></table>
<a name="rfc.section.6"></a><h3>6.
Subscribing and Unsubscribing</h3>
<p>Subscribing to a resource consists of three parts that may occur
immediately in sequence or have a delay.
</p>
<p></p>
<ul class="text">
<li>Requesting a subscription using the hub
</li>
<li>Confirming the subscription was actually desired
</li>
<li>Periodically reconfirming the subscription is still active
</li>
</ul>
<br /><hr class="insert" />
<div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
POST /pshb_endpoint HTTP/1.1
Host: www.nicehub.com
...
Content-Type: application/x-www-form-urlencoded
Content-Length: 200
hub.callback=http://www.reader.com/pshb&hub.mode=subscribe&
hub.verify=sync&oauth_token=XXXXXXIOEIWOEWOKEM922IOJK222NK2
-------------------------------------------------------------
HTTP/1.1 204 No Content
Date: Fri, 14 May 2010 20:54:17 GMT
Content-Length: 0
</pre></div><table border="0" cellpadding="0" cellspacing="2" align="center"><tr><td align="center"><font face="monaco, MS Sans Serif" size="1"><b> Requesting a subscription using the hub </b></font><br /></td></tr></table><hr class="insert" />
<p>Unsubscribing works in the same way, except with a single parameter
changed to indicate the desire to unsubscribe.
</p>
<a name="anchor5"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc"> TOC </a></td></tr></table>
<a name="rfc.section.6.1"></a><h3>6.1.
Subscriber Sends Subscription Request</h3>
<p>Subscription is initiated by the subscriber making an
<a class='info' href='#RFC2616'>HTTP<span> (</span><span class='info'>Fielding, R., Gettys, J., Mogul, J., Frystyk, H., Masinter, L., Leach, P., and T. Berners-Lee, “Hypertext Transfer Protocol -- HTTP/1.1,” .</span><span>)</span></a> [RFC2616] POST request to the hub URL.
Optionally this request can be signed using <a class='info' href='#OAuth_2_0'>OAuth 2.0<span> (</span><span class='info'>, “OAuth 2.0 Protocol (Draft),” .</span><span>)</span></a> [OAuth_2_0]
and transmitted as an <a class='info' href='#RFC2818'>HTTPS<span> (</span><span class='info'>Rescorla, E., “HTTP Over TLS,” May 2000.</span><span>)</span></a> [RFC2818] POST request.
This request has a Content-Type of <tt>application/x-www-form-urlencoded</tt>
(described in Section 17.13.4 of <a class='info' href='#W3C.REC-html401-19991224'>[W3C.REC‑html401‑19991224]<span> (</span><span class='info'>Raggett, D., Hors, A., and I. Jacobs, “HTML 4.01 Specification,” December 1999.</span><span>)</span></a>) and the following
parameters in its body:
</p>
<p></p>
<blockquote class="text"><dl>
<dt>hub.callback</dt>
<dd>REQUIRED. The subscriber's callback URL
where notifications should be delivered.
</dd>
<dt>hub.update_callback</dt>
<dd>OPTIONAL. The subscriber's callback URL
where content update notifications should be delivered. Will be invoked using the HTTP PUT method.
If not specified default to hub.callback
</dd>
<dt>hub.delete_callback</dt>
<dd>OPTIONAL. The subscriber's callback URL
where delete notifications should be delivered. Will be invoked using the HTTP DELETE method.
If not specified default to hub.callback
</dd>
<dt>hub.mode</dt>
<dd>REQUIRED. The literal string "subscribe" or
"unsubscribe", depending on the goal of the request.
</dd>
<dt>hub.topic</dt>
<dd>REQUIRED. The resource URL that the
subscriber wishes to subscribe to.
</dd>
<dt>hub.verify</dt>
<dd>REQUIRED. Keyword describing verification
modes supported by this subscriber, as described below. This
parameter may be repeated to indicate multiple supported
modes.
</dd>
<dt>hub.lease_seconds</dt>
<dd>OPTIONAL. Number of seconds for
which the subscriber would like to have the subscription active.
If not present or an empty value, the subscription will be
permanent (or active until <a class='info' href='#autorefresh'>automatic
refreshing<span> (</span><span class='info'>Automatic Subscription Refreshing</span><span>)</span></a> removes the subscription). Hubs MAY choose to
respect this value or not, depending on their own policies. This
parameter MAY be present for unsubscription requests and MUST be
ignored by the hub in that case.
</dd>
<dt>hub.secret</dt>
<dd>OPTIONAL. A subscriber-provided secret
string that will be used to compute an HMAC digest for <a class='info' href='#authednotify'>authorized content distribution<span> (</span><span class='info'>Authenticated Content Distribution</span><span>)</span></a>. If
not supplied, the HMAC digest will not be present for content
distribution requests. This parameter SHOULD only be specified
when the request was made over <a class='info' href='#RFC2818'>HTTPS<span> (</span><span class='info'>Rescorla, E., “HTTP Over TLS,” May 2000.</span><span>)</span></a> [RFC2818]. This parameter MUST be less than
200 bytes in length.
</dd>
<dt>hub.verify_token</dt>
<dd>OPTIONAL. A subscriber-provided
opaque token that will be echoed back in the verification request
to assist the subscriber in identifying which subscription request
is being verified. If this is not included, no token will be
included in the verification request.
</dd>
<dt>oauth_token</dt>
<dd>OPTIONAL. Use this field with
<a class='info' href='#OAuth_2_0'>OAuth 2.0<span> (</span><span class='info'>, “OAuth 2.0 Protocol (Draft),” .</span><span>)</span></a> [OAuth_2_0] to transmit a hub-provided
opaque token that will grant or deny access to the resource.
</dd>
</dl></blockquote><p>
</p>
<p>The following keywords are supported for hub.verify:
</p>
<p></p>
<blockquote class="text"><dl>
<dt>sync</dt>
<dd>The subscriber supports synchronous
verification, where the verification request must occur before the
subscription request's HTTP response is returned.
</dd>
<dt>async</dt>
<dd>The subscriber supports asynchronous
verification, where the verification request may occur at a later
point after the subscription request has returned.
</dd>
</dl></blockquote>
<p>Where repeated keywords are used, their order indicates the
subscriber's order of preference. Subscribers MUST use at least one of
the modes indicated in the list above, but MAY include additional
keywords defined by extension specifications. Hubs MUST ignore verify
mode keywords that they do not understand.
</p>
<p>Hubs MUST ignore additional request parameters they do not
understand.
</p>
<p>Hubs MUST allow subscribers to re-request subscriptions that are
already activate. Each subsequent request to a hub to subscribe or
unsubscribe MUST override the previous subscription state for a
specific topic URL and callback URL combination once the action is
verified. Any failures to confirm the subscription action MUST leave
the subscription state unchanged. This is required so subscribers can
renew their subscriptions before the lease seconds period is over
without any interruption.
</p>
<a name="anchor6"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc"> TOC </a></td></tr></table>
<a name="rfc.section.6.1.1"></a><h3>6.1.1.
Subscription Parameter Details</h3>
<p>The resource and callback URLs MUST NOT contain an anchor fragment.
These URLs MAY use <a class='info' href='#RFC2616'>HTTP<span> (</span><span class='info'>Fielding, R., Gettys, J., Mogul, J., Frystyk, H., Masinter, L., Leach, P., and T. Berners-Lee, “Hypertext Transfer Protocol -- HTTP/1.1,” .</span><span>)</span></a> [RFC2616] or <a class='info' href='#RFC2818'>HTTPS<span> (</span><span class='info'>Rescorla, E., “HTTP Over TLS,” May 2000.</span><span>)</span></a> [RFC2818] schemes. These URLs MAY have port
numbers specified; however, hubs MAY choose to disallow certain
ports based on their own policies (e.g., security) and return errors
for these requests. The topic URL can otherwise be free-form
following <a class='info' href='#RFC3986'>the URI spec<span> (</span><span class='info'>Berners-Lee, T., “Uniform Resource Identifiers (URI): Generic Syntax,” .</span><span>)</span></a> [RFC3986]. Hubs MUST
always decode non-reserved characters for these URL parameters; see
section 2.4 on <em>"When to Encode or Decode"</em>
in <a class='info' href='#RFC3986'>the URI spec<span> (</span><span class='info'>Berners-Lee, T., “Uniform Resource Identifiers (URI): Generic Syntax,” .</span><span>)</span></a> [RFC3986].
</p>
<p>The callback URL MAY contain arbitrary query string parameters
(e.g., <tt>?foo=bar&red=fish</tt>). Hubs MUST
preserve the query string during subscription verification by
appending new parameters to the end of the list using the <tt>&</tt> (ampersand) character to join. Existing
parameters with names that overlap with those used by verification
requests will not be overwritten; Hubs MUST only append verification
parameters to the existing list, if any. 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>
<p>Subscribers MAY choose to use <a class='info' href='#RFC2818'>HTTPS<span> (</span><span class='info'>Rescorla, E., “HTTP Over TLS,” May 2000.</span><span>)</span></a> [RFC2818]
for their callback URLs if they care about the privacy of
notifications as they come over the wire from the Hub. The use of
mechanisms (such as XML signatures) to verify the integrity of
notifications coming from the original publisher is out of the scope
of this specification.
</p>
<a name="anchor7"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc"> TOC </a></td></tr></table>
<a name="rfc.section.6.1.2"></a><h3>6.1.2.
Subscription Response Details</h3>
<p>The hub MUST respond to a subscription request with an HTTP 204
"No Content" response to indicate that the request was verified and
that the subscription is active. If the subscription has yet to be
verified (i.e., the hub is using asynchronous verification), the hub
MUST respond with a 202 "Accepted" code.
</p>
<p>If a hub finds any errors in the subscription request, an
appropriate HTTP error response code (4xx or 5xx) MUST be returned.
For example, for <a class='info' href='#OAuth_2_0'>OAuth 2.0<span> (</span><span class='info'>, “OAuth 2.0 Protocol (Draft),” .</span><span>)</span></a> [OAuth_2_0] requests
with expired tokens you would get a
</p>
<div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
HTTP/1.1 401 Unauthorized
WWW-Authenticate: Token realm='Service', error='token_expired'
</pre></div><p>
In the event of an error, hubs SHOULD return a description of the
error in the response body as plain text. Hubs MAY decide to reject
some callback URLs or topic URLs based on their own policies (e.g.,
domain authorization, topic URL port numbers).
</p>
<p>In synchronous mode, the verification (<a class='info' href='#verifysub'>Section 6.2<span> (</span><span class='info'>Hub Verifies Intent of the Subscriber</span><span>)</span></a>) MUST be completed before the hub returns
a response. In asynchronous mode, the verification MAY be deferred
until a later time. This is useful to enable hubs to defer work;
this could allow them to alleviate servers under heavy load or do
verification work in batches.
</p>
<a name="verifysub"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc"> TOC </a></td></tr></table>
<a name="rfc.section.6.2"></a><h3>6.2.
Hub Verifies Intent of the Subscriber</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 <a class='info' href='#RFC2616'>HTTP<span> (</span><span class='info'>Fielding, R., Gettys, J., Mogul, J., Frystyk, H., Masinter, L., Leach, P., and T. Berners-Lee, “Hypertext Transfer Protocol -- HTTP/1.1,” .</span><span>)</span></a> [RFC2616] 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
17.13.4 of <a class='info' href='#W3C.REC-html401-19991224'>[W3C.REC‑html401‑19991224]<span> (</span><span class='info'>Raggett, D., Hors, A., and I. Jacobs, “HTML 4.01 Specification,” December 1999.</span><span>)</span></a>):
</p>
<p></p>
<blockquote class="text"><dl>
<dt>hub.mode</dt>
<dd>REQUIRED. The literal string "subscribe" or
"unsubscribe", which matches the original request to the hub from
the subscriber.
</dd>
<dt>hub.topic</dt>
<dd>REQUIRED. The topic URL given in the
corresponding subscription request.
</dd>
<dt>hub.challenge</dt>
<dd>REQUIRED. A hub-generated, random
string that MUST be echoed by the subscriber to verify the
subscription.
</dd>
<dt>hub.lease_seconds</dt>
<dd>REQUIRED/OPTIONAL. 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 MUST supply
this parameter for subscription requests. This parameter MAY be
present for unsubscribe requests and MUST be ignored by
subscribers during unsubscription.
</dd>
<dt>hub.verify_token</dt>
<dd>OPTIONAL. The subscriber-provided
opaque token from the corresponding subscription request, if one
was provided.
</dd>
</dl></blockquote>
<a name="anchor8"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc"> TOC </a></td></tr></table>
<a name="rfc.section.6.2.1"></a><h3>6.2.1.
Verification Details</h3>
<p>The subscriber MUST confirm that the <tt>hub.topic
</tt> and <tt>hub.verify_token</tt> correspond
to a pending subscription or unsubscription that it wishes to carry
out. If so, the subscriber MUST respond with an HTTP success (2xx)
code with a response body equal to the <tt>hub.challenge</tt>
parameter. If the subscriber does not agree with the action, the
subscriber MUST respond with a 404 "Not Found" response.
</p>
<p>For synchronous verification, the hub MUST consider other server
response codes (3xx, 4xx, 5xx) to mean that the verification request
has immediately failed and no retries should occur. If the
subscriber returns an HTTP success (2xx) but the content body does
not match the <tt>hub.challenge</tt> parameter,
the hub MUST also consider verification to have failed.
</p>
<p>For asynchronous verification, the hub MUST consider other server
response codes (3xx, 4xx, and 5xx) to mean that the subscription
action was <em>temporarily</em> not verified. If
the subscriber returns an HTTP success (2xx) but the content body
does not match the <tt>hub.challenge</tt>
parameter, the hub MUST consider this to be a <em>temporary</em>
failure and retry. The hub SHOULD retry verification a reasonable
number of times over the course of a longer time period (e.g., 6
hours) until a definite acknowledgement (positive or negative) is
received. If a definite response still cannot be determined after
this retry period, the subscription action verification MUST be
abandoned, leaving the previous subscription state.
</p>
<p>Hubs MAY make the <tt>hub.lease_seconds</tt>
equal to the period the subscriber passed in their subscription
request but MAY change the value depending on the hub's policies. To
sustain a temporary subscription, the subscriber MUST re-request the
subscription on the hub before <tt>hub.lease_seconds</tt>
seconds has elapsed. For permanent subscriptions with no <tt>hub.lease_seconds</tt> value specified, the behavior
is different as described in the section on <a class='info' href='#autorefresh'>automatic subscription refreshing<span> (</span><span class='info'>Automatic Subscription Refreshing</span><span>)</span></a>.
</p>
<a name="autorefresh"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc"> TOC </a></td></tr></table>
<a name="rfc.section.6.3"></a><h3>6.3.
Automatic Subscription Refreshing</h3>
<p>Before a subscription expires (i.e., before <tt>hub.lease_seconds</tt>
elapses), Hubs MUST recheck with subscribers to see if a continued
subscription is desired. Hubs do this by sending the subscriber a
<a class='info' href='#verifysub'>verification request<span> (</span><span class='info'>Hub Verifies Intent of the Subscriber</span><span>)</span></a> with <tt>hub.mode</tt> equal to subscribe. This request MUST
match the original verification request sent to the subscriber (but
with a new <tt>hub.challenge</tt>).
</p>
<p>The response codes returned by the subscriber MUST be interpreted
the same way as during a subscriber-initiated verification flow.
However, this refresh request MUST behave like an initial subscription
request; this means that if an auto-refresh response from the
subscriber constantly returns an error, the hub MUST give up on the
subscription verification action altogether and remove the
subscription.
</p>
<p>In the case of permanent subscriptions (with no <tt>hub.lease_seconds</tt> specified in the original
request), the <tt>hub.lease_seconds</tt> value
supplied by the hub in the verification request to the subscriber
SHOULD represent how many seconds until the hub expects it will next
initiate automatic subscription refreshing to ensure that the
subscriber is still interested in the topic. This behavior provides
the best of both worlds: maximum simplicity of the subscriber through
infinitely-long subscriptions, but still garbage collectable
subscriptions for hub hygiene.
</p>
<a name="publishing"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc"> TOC </a></td></tr></table>
<a name="rfc.section.7"></a><h3>7.
Publishing</h3>
<p>A publisher pings the hub with the topic URL(s) which have been
updated and the hub schedules those topics to be fetched and delivered.
Because it's just a ping to notify the hub of the topic URL (without a
payload), no authentication from the publisher is required.
</p>
<a name="anchor9"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc"> TOC </a></td></tr></table>
<a name="rfc.section.7.1"></a><h3>7.1.
New Content Notification</h3>
<p>When new content is added to a feed, a notification is sent to the
hub by the publisher. The hub MUST accept a POST request to the hub
URL containing the notification. This request MUST have a Content-Type
of <tt>application/x-www-form-urlencoded
</tt> (described in Section 17.13.4 of <a class='info' href='#W3C.REC-html401-19991224'>[W3C.REC‑html401‑19991224]<span> (</span><span class='info'>Raggett, D., Hors, A., and I. Jacobs, “HTML 4.01 Specification,” December 1999.</span><span>)</span></a>) and the following
parameters in its body:
</p>
<p></p>
<blockquote class="text"><dl>
<dt>hub.mode</dt>
<dd>REQUIRED. The literal string "publish".
</dd>
<dt>hub.url</dt>
<dd>REQUIRED. The topic URL of the topic that
has been updated. This field may be repeated to indicate multiple
topics that have been updated.
</dd>
<dt>oauth_token</dt>
<dd>OPTIONAL if the Hub requires that the
author and content generator are identified prior to granting
distribution access and/or to provide access control.
</dd>
</dl></blockquote>
<p>The new content notification is a signal to the hub that there is
new content available. The hub SHOULD arrange for a content fetch
request (<a class='info' href='#contentfetch'>Section 7.2<span> (</span><span class='info'>Content Fetch</span><span>)</span></a>) to be performed in the
near future to retrieve the new content. If the notification was
acceptable, the hub MUST return a 204 No Content response. If the
notification is not acceptable for some reason, the hub MUST return an
appropriate HTTP error response code (4xx and 5xx). Hubs MUST return a
204 No Content response even when they do not have any subscribers for
all of the specified topic URLs.
</p>
<a name="contentfetch"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc"> TOC </a></td></tr></table>
<a name="rfc.section.7.2"></a><h3>7.2.
Content Fetch</h3>
<p>When the hub wishes to retrieve new content for a topic, the hub
sends an <a class='info' href='#RFC2616'>HTTP<span> (</span><span class='info'>Fielding, R., Gettys, J., Mogul, J., Frystyk, H., Masinter, L., Leach, P., and T. Berners-Lee, “Hypertext Transfer Protocol -- HTTP/1.1,” .</span><span>)</span></a> [RFC2616] GET request to the topic
URL. The hub MUST follow HTTP redirects. The Hub SHOULD use best
practices for caching headers in its requests (e.g., <tt>If-None-Match</tt>, <tt>If-Modified-Since</tt>).
</p>
<p>The request SHOULD include the header field <tt>User-Agent</tt>
in the form expected by <a class='info' href='#RFC2616'>HTTP<span> (</span><span class='info'>Fielding, R., Gettys, J., Mogul, J., Frystyk, H., Masinter, L., Leach, P., and T. Berners-Lee, “Hypertext Transfer Protocol -- HTTP/1.1,” .</span><span>)</span></a> [RFC2616]. The header
MAY have one or more additional suffixes like <tt>(example.com; 20 subscribers)</tt>
to indicate the number of subscriptions the hub has active for this
topic.
</p>
<p>If present, the first suffix MUST indicate the total number of
subscriptions the hub has aggregated across all subscriber domains by
means of the <tt>X-Hub-On-Behalf-Of</tt> header
(<a class='info' href='#contentdistribution'>Section 7.3<span> (</span><span class='info'>Content Distribution</span><span>)</span></a>). Any additional suffixes
indicate a breakdown of subscriber counts across subscriber domains.
This allows content publishers to distinguish the source of their
subscriber counts and mitigate subscriber count spam. An example
header could be (ignoring line-wrapping):
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
User-Agent: MyHub (+http://hub.example.com; 26 subscribers)
(sub.example.com; 4 subscribers)
(other-sub.example.com; 22 subscribers)
</pre></div>
<p>If, after a content fetch, the hub determines that the topic feed
content has changed, the hub MUST send information about the changes
to each of the subscribers to the topic (<a class='info' href='#contentdistribution'>Section 7.3<span> (</span><span class='info'>Content Distribution</span><span>)</span></a>). Hubs MUST consider new feed
entries, updated entries, deleted entries or changes to the surrounding
feed document as significant content changes that require content
distribution.
</p>
<a name="contentdistribution"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc"> TOC </a></td></tr></table>
<a name="rfc.section.7.3"></a><h3>7.3.
Content Distribution</h3>
<p>A content distribution request is an <a class='info' href='#RFC2616'>HTTP<span> (</span><span class='info'>Fielding, R., Gettys, J., Mogul, J., Frystyk, H., Masinter, L., Leach, P., and T. Berners-Lee, “Hypertext Transfer Protocol -- HTTP/1.1,” .</span><span>)</span></a> [RFC2616] POST, PUT or DELETE request from hub to the subscriber's
callback URL with the list of new and changed entries. The Content-Type header will
indicate the format of the request.
Hubs MAY transform the content type and request body as desired (e.g.,
for language translation).
</p>
<p>If the document represents a single feed being replicated for the
subscriber, then the feed-level elements SHOULD be preserved aside
from the <tt>atom:entry</tt> or <tt>rss:item</tt> elements. However, the <tt>atom:id</tt> element MUST be reproduced exactly. The
other <tt>atom:updated</tt> and <tt>atom:title</tt> elements required by the Atom
specification SHOULD be present. Each <tt>atom:entry</tt>
or <tt>rss:item</tt> element in the feed contains
the content from an entry in the single topic that the subscriber has
an active subscription for. Essentially, in the single feed case the
subscriber will receive a feed document that looks like the original
but with old content removed.
</p>
<p>The successful response from the subscriber's callback URL MUST be
an HTTP success (2xx) code. The hub MUST consider all other subscriber
response codes as failures; that means subscribers MUST not use HTTP
redirects for moving subscriptions. The response body from the
subscriber MUST be ignored by the hub. Hubs SHOULD retry notifications
repeatedly until successful (up to some reasonable maximum over a
reasonable time period). Subscribers SHOULD respond to notifications
as quickly as possible; their success response code SHOULD only
indicate receipt of the message, not acknowledgment that it was
successfully processed by the subscriber.
</p>
<p>The subscriber's callback response MAY include the header field
<tt>X-Hub-On-Behalf-Of</tt> with an integer value,
possibly approximate, representing the number of subscribers on behalf
of which this feed notification was delivered. This value SHOULD be
aggregated by the hub across all subscribers and used to provide the
subscriber counts in the <tt>User-Agent</tt> header
field sent to publishers (<a class='info' href='#contentfetch'>Section 7.2<span> (</span><span class='info'>Content Fetch</span><span>)</span></a>). Hubs
MAY ignore or respect <tt>X-Hub-On-Behalf-Of</tt>
values from subscribers depending on their own policies (i.e., to
prevent spam).
</p>
<a name="authednotify"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc"> TOC </a></td></tr></table>
<a name="rfc.section.7.4"></a><h3>7.4.
Authenticated Content Distribution</h3>
<p>If the subscriber supplied a value for <tt>hub.secret</tt>
in their subscription request, the hub MUST generate an HMAC signature
of the payload and include that signature in the request headers of
the content distribution request. The <tt>X-Hub-Signature</tt>
header's value MUST be in the form <tt>sha1=signature</tt>
where <tt>signature</tt> is a 40-byte, hexadecimal
representation of a <a class='info' href='#RFC3174'>SHA1 signature<span> (</span><span class='info'>Eastlake, D. and P. Jones, “US Secure Hash Algorithm 1 (SHA1),” September 2001.</span><span>)</span></a> [RFC3174]. The
signature MUST be computed using the <a class='info' href='#RFC2104'>HMAC
algorithm<span> (</span><span class='info'>Krawczyk, H., Bellare, M., and R. Canetti, “HMAC: Keyed-Hashing for Message Authentication,” .</span><span>)</span></a> [RFC2104] with the request body as the data and the <tt>hub.secret</tt> as the key.
</p>
<p>When subscribers receive a content distribution request with the
<tt>X-Hub-Signature</tt> header specified, they
SHOULD recompute the SHA1 signature with the shared secret using the
same method as the hub. If the signature does not match, subscribers
MUST still return a 2xx success response to acknowledge receipt, but
locally ignore the message as invalid. Using this technique along with
HTTPS for subscription requests enables simple subscribers to receive
authenticated content delivery from hubs without the need for
subscribers to run an HTTPS server.
</p>
<a name="aggregatedistribution"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc"> TOC </a></td></tr></table>
<a name="rfc.section.7.5"></a><h3>7.5.
Aggregated Content Distribution</h3>
<p>For Atom feeds and JSON Activity Streams only. Pending further review.
</p>
<p>When a subscriber indicates the same callback URL is used for
multiple subscriptions, hubs MAY choose to combine content delivery
requests into a single payload containing an aggregated set of feeds.
This bulk delivery results in fewer requests and more efficient
distribution. If the subscriber indicated a <tt>hub.secret</tt>
value for these overlapping subscriptions, the secret MUST also be the
same for all subscriptions. This allows the hub to generate a single
<tt>X-Hub-Signature</tt> header to sign the entire
payload. Hubs MUST return an error response (4xx, 5xx) for
subscription requests with overlapping callback URLs and different
secret values.
</p>
<p>With an aggregated set of feeds, the hub SHOULD reproduce all of
the elements from the source feed <em>inside</em>
the corresponding <tt>atom:entry</tt> in the
content distribution request by using an <tt>atom:source</tt>
element. However, the <tt>atom:id</tt> value MUST
be reproduced exactly within the source element. If the source entry
does not have an <tt>atom:source</tt> element, the
hub MUST create an <tt>atom:source</tt> element
containing the <tt>atom:id</tt> element. The hub
SHOULD also include the <tt>atom:title</tt> element
and an <tt>atom:link</tt> element with <tt>rel="self"</tt> values that are functionally
equivalent to the corresponding elements in the original topic
feed.
</p>
<p>Example aggregated feed:
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre><?xml version="1.0"?>
<atom:feed>
<title>Aggregated feed</title>
<updated>2008-08-11T02:17:44Z</updated>
<id>http://myhub.example.com/aggregated?1232427842-39823</id>
<entry>
<source>
<id>http://www.example.com/foo</id>
<link rel="self" href="http://publisher.example.com/foo.xml" />
<author>
<name>Mr. Bar</name>
</author>
</source>
<title>Testing Foo</title>
<link href="http://publisher.example.com/foo24.xml" />
<id>http://publisher.example.com/foo24.xml</id>
<updated>2008-08-11T02:15:01Z</updated>
<content>
This is some content from the user named foo.
</content>
</entry>