-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathdraft-ietf-webpush-protocol.xml
More file actions
2016 lines (1943 loc) · 89.4 KB
/
draft-ietf-webpush-protocol.xml
File metadata and controls
2016 lines (1943 loc) · 89.4 KB
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
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="rfc2629.xslt"?>
<!DOCTYPE rfc SYSTEM "rfc2629.dtd">
<?rfc strict="yes" ?>
<?rfc toc="yes"?>
<?rfc tocdepth="4"?>
<?rfc symrefs="yes"?>
<?rfc sortrefs="yes" ?>
<?rfc compact="yes" ?>
<?rfc subcompact="no" ?>
<rfc category="std" ipr="trust200902" docName="draft-ietf-webpush-protocol-latest">
<front>
<title abbrev="HTTP Web Push">
Generic Event Delivery Using HTTP Push
</title>
<author initials="M." surname="Thomson" fullname="Martin Thomson">
<organization>Mozilla</organization>
<address>
<postal>
<street>331 E Evelyn Street</street>
<city>Mountain View</city>
<region>CA</region>
<code>94041</code>
<country>US</country>
</postal>
<email>martin.thomson@gmail.com</email>
</address>
</author>
<author initials="E." surname="Damaggio" fullname="Elio Damaggio">
<organization>Microsoft</organization>
<address>
<postal>
<street>One Microsoft Way</street>
<city>Redmond</city>
<region>WA</region>
<code>98052</code>
<country>US</country>
</postal>
<email>elioda@microsoft.com</email>
</address>
</author>
<author initials="B." surname="Raymor" fullname="Brian Raymor" role="editor">
<organization>Microsoft</organization>
<address>
<postal>
<street>One Microsoft Way</street>
<city>Redmond</city>
<region>WA</region>
<code>98052</code>
<country>US</country>
</postal>
<email>brian.raymor@microsoft.com</email>
</address>
</author>
<date year="2016"/>
<area>RAI</area>
<workgroup>WEBPUSH</workgroup>
<keyword>Internet-Draft</keyword>
<keyword>HTTP</keyword>
<keyword>HTTP2</keyword>
<keyword>Push</keyword>
<keyword>WebPush</keyword>
<abstract>
<t>
A simple protocol for the delivery of real-time events to user agents is
described. This scheme uses HTTP/2 server push.
</t>
</abstract>
</front>
<middle>
<section anchor="intro" title="Introduction">
<t>
Many applications on mobile and embedded devices require continuous
access to network communications so that real-time events - such as
incoming calls or messages - can be delivered (or "pushed") in a timely
fashion. These devices typically have limited power reserves, so finding
more efficient ways to serve application requirements greatly benefits
the application ecosystem.
</t>
<t>
One significant contributor to power usage is the radio. Radio
communications consume a significant portion of the energy budget
on a wireless device.
</t>
<t>
Uncoordinated use of persistent connections or sessions from multiple
applications can contribute to unnecessary use of the device radio,
since each independent session can incur its own overhead. In
particular, keep alive traffic used to ensure that middleboxes do not
prematurely time out sessions, can result in significant waste.
Maintenance traffic tends to dominate over the long term, since events
are relatively rare.
</t>
<t>
Consolidating all real-time events into a single session ensures more
efficient use of network and radio resources. A single service
consolidates all events, distributing those events to applications as
they arrive. This requires just one session, avoiding duplicated
overhead costs.
</t>
<t>
The <xref target="API">W3C Push API</xref> describes an API that
enables the use of a consolidated push service from web applications.
This document expands on that work by describing a protocol that can be used to:
<list style="symbols">
<t>
request the delivery of a push message to a user agent,
</t>
<t>
create new push message delivery subscriptions, and
</t>
<t>
monitor for new push messages.
</t>
</list>
</t>
<t>
A standardized method of event delivery is particularly important for
the W3C Push API, where application servers might need to use multiple
push services. The subscription, management and monitoring functions
are currently fulfilled by proprietary protocols; these are adequate,
but do not offer any of the advantages that standardization affords.
</t>
<t>
This document intentionally does not describe how a push service is
discovered. Discovery of push services is left for future efforts, if
it turns out to be necessary at all. User agents are expected to be
configured with a URL for a push service.
</t>
<section anchor="terminology" title="Conventions and Terminology">
<t>
The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
"SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this
document are to be interpreted as described in <xref target="RFC2119"/>.
</t>
<t>
This document defines the following terms:
<list style="hanging">
<t hangText="application:">
Both the sender and ultimate consumer of push messages. Many
applications have components that are run on a user agent and
other components that run on servers.
</t>
<t hangText="application server:">
The component of an application that usually runs on a server and
requests the delivery of a push message.
</t>
<t hangText="push message subscription:">
A message delivery context that is established between the user
agent and the push service and shared with the application server.
All push messages are associated with a push message subscription.
</t>
<t hangText="push message subscription set:">
A message delivery context that is established between the user
agent and the push service that collects multiple push message
subscriptions into a set.
</t>
<t hangText="push message:">
A message sent from an application server to a user agent via a
push service.
</t>
<t hangText="push message receipt:">
A message delivery confirmation sent from the push service to the
application server.
</t>
<t hangText="push service:">
A service that delivers push messages to user agents.
</t>
<t hangText="user agent:">
A device and software that is the recipient of push messages.
</t>
</list>
</t>
<t>
Examples in this document use the <xref target="RFC7230">HTTP/1.1
message format</xref>. Many of the exchanges can be completed using
HTTP/1.1:
<list style="symbols">
<t>
<xref target="message_subscription">Subscribing for Push Messages</xref>
</t>
<t>
<xref target="send">Requesting Push Message Delivery</xref>
</t>
<t>
<xref target="replace">Replacing Push Messages</xref>
</t>
<t>
<xref target="acknowledge_message">Acknowledging Push Messages</xref>
</t>
</list>
When an example depends on HTTP/2 server push, the more verbose frame format
from <xref target="RFC7540"/> is used:
<list style="symbols">
<t>
<xref target="monitor-subscription">Receiving Push Messages for a Subscription</xref>
</t>
<t>
<xref target="monitor-set">Receiving Push Messages for a Subscription Set</xref>
</t>
<t>
<xref target="receive_receipt">Receiving Push Message Receipts</xref>
</t>
</list>
</t>
<t>
All examples use HTTPS over the default port (443) rather than the registered port
(WEBPUSH-PORT). A push service deployment might prefer this configuration to maximize
chances for user agents to reach the service. A push service might use HTTP alternative
services to redirect a user agent to the registered port (WEBPUSH-PORT) to gain the benefits of the
standardized HTTPS port without sacrificing reachability (see <xref target="connecting"/>).
This would only be apparent in the examples through the inclusion of the Alt-Used header
field <xref target="RFC7838"/> in requests from the user agent to the push service.
</t>
<t>
Examples do not include specific methods for push message encryption
or application server authentication because the protocol does not define
a mandatory system. The examples in <xref target="I-D.ietf-webpush-vapid">Voluntary Application Server Identification</xref>
and <xref target="I-D.ietf-webpush-encryption">Message Encryption for WebPush</xref>
demonstrate the approach adopted by the <xref target="API">W3C Push API</xref> for
its requirements.
</t>
</section>
</section>
<section title="Overview">
<t>
A general model for push services includes three basic actors: a user
agent, a push service, and an application (server).
</t>
<figure anchor="fig-arch" title="Webpush Architecture">
<artwork><![CDATA[
+-------+ +--------------+ +-------------+
| UA | | Push Service | | Application |
+-------+ +--------------+ | Server |
| | +-------------+
| Subscribe | |
|--------------------->| |
| Monitor | |
|<====================>| |
| | |
| Distribute Push Resource |
|-------------------------------------------->|
| | |
: : :
| | Push Message |
| Push Message |<---------------------|
|<---------------------| |
| | |
]]></artwork>
</figure>
<t>
At the very beginning of the process, a new message subscription is
created by the user agent and then distributed to its application
server. This subscription is the basis of all future interactions between
the actors. A subscription is used by the application server to send messages to
the push service for being delivered to the user agent. It is used by
the user agent to monitor the push service for any incoming message.
</t>
<t>
To offer more control for authorization, a message subscription is
modeled as two resources with different capabilities:
<list style="symbols">
<t>
A subscription resource is used to receive messages from a
subscription and to delete a subscription. It is private to the user
agent.
</t>
<t>
A push resource is used to send messages to a subscription. It is
public and shared by the user agent with its application server.
</t>
</list>
</t>
<t>
It is expected that a unique subscription will be distributed to each
application; however, there are no inherent cardinality constraints in
the protocol. Multiple subscriptions might be created for the same
application, or multiple applications could use the same subscription.
Note however that sharing subscriptions has security and privacy
implications.
</t>
<t>
Subscriptions have a limited lifetime. They can also be terminated by
either the push service or user agent at any time. User agents and
application servers must be prepared to manage changes in subscription
state.
</t>
<section anchor="resources" title="HTTP Resources">
<t>
This protocol uses <xref target="RFC7230">HTTP resources</xref> and
<xref target="RFC5988">link relations</xref>. The following resources
are defined:
<list style="hanging">
<t hangText="push service:">
This resource is used to create push message subscriptions
(<xref target="message_subscription"/>). A URL for the push
service is configured into user agents.
</t>
<t hangText="push message subscription:">
This resource provides read and delete access for a message
subscription. A user agent <xref target="monitor-subscription">receives push
messages</xref> using a push message subscription. Every push
message subscription has exactly one push resource associated with
it.
</t>
<t hangText="push message subscription set:">
This resource provides read and delete access for a collection of push
message subscriptions. A user agent <xref target="monitor-set">receives
push messages</xref> for all the push message subscriptions in the set. A
link relation of type "urn:ietf:params:push:set" identifies a push message
subscription set.
</t>
<t hangText="push:">
An application server <xref target="send">requests the delivery</xref> of a
push message using a push resource. A link relation of type "urn:ietf:params:push"
identifies a push resource.
</t>
<t hangText="push message:">
The push service creates a push message resource to identify push messages that
have been <xref target="send">accepted for delivery</xref>. The push message
resource is also deleted by the user agent to
<xref target="acknowledge_message">acknowledge receipt</xref> of a push message.
</t>
<t hangText="receipt subscription:">
An application server <xref target="request-receipt">receives
delivery confirmations</xref> for push messages using a receipt
subscription. A link relation of type "urn:ietf:params:push:receipt"
identifies a receipt subscription.
</t>
</list>
</t>
</section>
</section>
<section anchor="connecting" title="Connecting to the Push Service">
<t>
The push service MUST use HTTP over TLS [RFC2818] following the recommendations in [RFC7525].
The push service shares the same default port number (443/TCP) with HTTPS, but MAY
also advertise the IANA allocated TCP System Port (WEBPUSH-PORT) using HTTP alternative services
<xref target="RFC7838"/>.
</t>
<t>
While the default port (443) offers broad reachability characteristics, it is most
often used for web browsing scenarios with a lower idle timeout than other ports
configured in middleboxes. For webpush scenarios, this would contribute to unnecessary
radio communications to maintain the connection on battery-powered devices.
</t>
<t>
Advertising the alternate port (WEBPUSH-PORT) allows middleboxes to optimize idle timeouts
for connections specific to push scenarios with the expectation that data exchange will be
infrequent.
</t>
<t>
Middleboxes SHOULD comply with REQ-5 in <xref target="RFC5382"/> which requires that
"the value of the 'established connection idle-timeout' MUST NOT be less than
2 hours 4 minutes".
</t>
</section>
<section anchor="message_subscription" title="Subscribing for Push Messages">
<t>
A user agent sends a POST request to its configured push service
resource to create a new subscription.
</t>
<figure>
<artwork type="inline"><![CDATA[
POST /subscribe HTTP/1.1
Host: push.example.net
]]></artwork>
</figure>
<t>
A 201 (Created) response indicates that the push subscription was
created. A URI for the push message subscription resource that was
created in response to the request MUST be returned in the Location
header field.
</t>
<t>
The push service MUST provide a URI for the push resource corresponding
to the push message subscription in a link relation of type
"urn:ietf:params:push".
</t>
<t>
An application-specific method is used to distribute the push URI to the
application server. Confidentiality protection and application server
authentication MUST be used to ensure that this URI is not disclosed
to unauthorized recipients (<xref target="authorization"/>).
</t>
<figure>
<artwork type="inline">
<![CDATA[
HTTP/1.1 201 Created
Date: Thu, 11 Dec 2014 23:56:52 GMT
Link: </push/JzLQ3raZJfFBR0aqvOMsLrt54w4rJUsV>;
rel="urn:ietf:params:push"
Link: </subscription-set/4UXwi2Rd7jGS7gp5cuutF8ZldnEuvbOy>;
rel="urn:ietf:params:push:set"
Location: https://push.example.net/subscription/LBhhw0OohO-Wl4Oi971UG
]]></artwork>
</figure>
<section title="Collecting Subscriptions into Sets">
<t>
Collecting multiple push message subscriptions into a subscription set
can represent a significant efficiency improvement for push services
and user agents. The push service MAY provide a URI for a subscription
set resource in a link relation of type "urn:ietf:params:push:set".
</t>
<t>
When a subscription set is returned in a push message subscription
response, the user agent SHOULD include this subscription set in a link
relation of type "urn:ietf:params:push:set" in subsequent requests to
create new push message subscriptions.
</t>
<t>
A user agent MAY omit the subscription set if it is unable to receive
push messages in an aggregated way for the lifetime of the subscription.
This might be necessary if the user agent is monitoring subscriptions on
behalf of other push message receivers.
</t>
<figure>
<artwork type="inline">
<![CDATA[
POST /subscribe HTTP/1.1
Host: push.example.net
Link: </subscription-set/4UXwi2Rd7jGS7gp5cuutF8ZldnEuvbOy>;
rel="urn:ietf:params:push:set"
]]></artwork>
</figure>
<t>
The push service SHOULD return the same subscription set in its response, although
it MAY return a new subscription set if it is unable to reuse the one provided
by the user agent.
</t>
<figure>
<artwork type="inline">
<![CDATA[
HTTP/1.1 201 Created
Date: Thu, 11 Dec 2014 23:56:52 GMT
Link: </push/YBJNBIMwwA_Ag8EtD47J4A>;
rel="urn:ietf:params:push"
Link: </subscription-set/4UXwi2Rd7jGS7gp5cuutF8ZldnEuvbOy>;
rel="urn:ietf:params:push:set"
Location: https://push.example.net/subscription/i-nQ3A9Zm4kgSWg8_ZijV
]]></artwork>
</figure>
<t>
A push service MUST return a 400 (Bad Request) status code for requests which
contain an invalid subscription set. A push service MAY return a 429
(Too Many Requests) status code <xref target="RFC6585"/> to reject requests
which omit a subscription set.
</t>
<t>
How a push service detects that requests originate from the same user agent
is implementation-specific but could take ambient information into
consideration, such as the TLS connection, source IP address and port.
Implementers are reminded that some heuristics can produce false
positives and cause requests to be rejected incorrectly.
</t>
</section>
</section>
<section anchor="send" title="Requesting Push Message Delivery">
<t>
An application server requests the delivery of a push message by sending
a HTTP POST request to a push resource distributed to the application
server by a user agent. The content of the push message is included
in the body of the request.
</t>
<figure>
<artwork type="inline">
<![CDATA[
POST /push/JzLQ3raZJfFBR0aqvOMsLrt54w4rJUsV HTTP/1.1
Host: push.example.net
TTL: 15
Content-Type: text/plain;charset=utf8
Content-Length: 36
iChYuI3jMzt3ir20P8r_jgRR-dSuN182x7iB
]]></artwork>
</figure>
<figure>
<preamble>
A 201 (Created) response indicates that the push message was accepted.
A URI for the push message resource that was created in response to
the request MUST be returned in the Location header field. This does not
indicate that the message was delivered to the user agent.
</preamble>
<artwork type="inline"><![CDATA[
HTTP/1.1 201 Created
Date: Thu, 11 Dec 2014 23:56:55 GMT
Location: https://push.example.net/message/qDIYHNcfAIPP_5ITvURr-d6BGt
]]></artwork>
</figure>
<section anchor="request-receipt" title="Requesting Push Message Receipts">
<t>
An application server can include the <xref target="RFC7240">Prefer header
field</xref> with the "respond-async" preference to request confirmation
from the push service when a push message is delivered and then acknowledged
by the user agent. The push service MUST support delivery confirmations.
</t>
<figure>
<artwork type="inline">
<![CDATA[
POST /push/JzLQ3raZJfFBR0aqvOMsLrt54w4rJUsV HTTP/1.1
Host: push.example.net
Prefer: respond-async
TTL: 15
Content-Type: text/plain;charset=utf8
Content-Length: 36
iChYuI3jMzt3ir20P8r_jgRR-dSuN182x7iB
]]>
</artwork>
</figure>
<figure>
<preamble>
When the push service accepts the message for delivery with confirmation, it MUST
return a 202 (Accepted) response. A URI for the push message resource that was
created in response to the request MUST be returned in the Location header field.
The push service MUST also provide a URI for the receipt subscription resource in
a link relation of type "urn:ietf:params:push:receipt".
</preamble>
<artwork type="inline">
<![CDATA[
HTTP/1.1 202 Accepted
Date: Thu, 11 Dec 2014 23:56:55 GMT
Link: </receipt-subscription/3ZtI4YVNBnUUZhuoChl6omUvG4ZM>;
rel="urn:ietf:params:push:receipt"
Location: https://push.example.net/message/qDIYHNcfAIPP_5ITvURr-d6BGt
]]>
</artwork>
</figure>
<t>
For subsequent receipt requests to the same origin <xref target="RFC6454"/>,
the application server SHOULD include the returned receipt subscription in
a link relation of type "urn:ietf:params:push:receipt". This gives the push
service an option to aggregate the receipts. The push service SHOULD return
the same receipt subscription in its response, although it MAY return a new
receipt subscription if it is unable to reuse the one provided by the application
server.
</t>
<t>
An application server MAY omit the receipt subscription if it is
unable to receive receipts in an aggregated way for the lifetime of
the receipt subscription. This might be necessary if the application
server is monitoring receipt subscriptions on the behalf of other
push message senders.
</t>
<t>
A push service MUST return a 400 (Bad Request) status code for requests which contain
an invalid receipt subscription. If a push service wishes to limit the number of
receipt subscriptions that it maintains, it MAY return a 429 (Too Many Requests)
status code <xref target="RFC6585"/> to reject receipt requests which omit a receipt
subscription.
</t>
</section>
<section anchor="ttl" title="Push Message Time-To-Live">
<t>
A push service can improve the reliability of push message delivery
considerably by storing push messages for a period. User agents are
often only intermittently connected, and so benefit from having short
term message storage at the push service.
</t>
<t>
Delaying delivery might also be used to batch communication with the
user agent, thereby conserving radio resources.
</t>
<t>
Some push messages are not useful once a certain period of time
elapses. Delivery of messages after they have ceased to be relevant
is wasteful. For example, if the push message contains a call
notification, receiving a message after the caller has abandoned the
call is of no value; the application at the user agent is forced to
suppress the message so that it does not generate a useless alert.
</t>
<t>
An application server MUST include the TTL (Time-To-Live) header field in
its request for push message delivery. The TTL header field contains a value
in seconds that suggests how long a push message is retained by the push service.
</t>
<figure>
<preamble>
The TTL rule specifies a non-negative integer, representing time in seconds.
A recipient parsing and converting a TTL value to binary form SHOULD use an
arithmetic type of at least 31 bits of non-negative integer range. If a recipient
receives a TTL value greater than the greatest integer it can represent, or if any
of its subsequent calculations overflows, it MUST consider the value to be 2147483648 (2^31).
</preamble>
<artwork type="abnf"><![CDATA[
TTL = 1*DIGIT
]]></artwork>
</figure>
<t>
A push service MUST return a 400 (Bad Request) status code in response to
requests that omit the TTL header field.
</t>
<t>
A push service MAY retain a push message for a shorter duration than requested.
It indicates this by returning a TTL header field in its response with the actual
TTL. This TTL value MUST be less than or equal to the value provided by the
application server.
</t>
<t>
Once the TTL period elapses, the push service MUST NOT attempt to deliver the push
message to the user agent. A push service might adjust the TTL value to account for
time accounting errors in processing. For instance, distributing a push message
within a server cluster might accrue errors due to clock skew or propagation delays.
</t>
<t>
A push service is not obligated to account for time spent by the
application server in sending a push message to the push service, or
delays incurred while sending a push message to the user agent. An
application server needs to account for transit delays in selecting a
TTL header field value.
</t>
<t>
A Push message with a zero TTL is immediately delivered if the user agent is
available to receive the message. After delivery, the push service is permitted
to immediately remove a push message with a zero TTL. This might occur before the
user agent acknowledges receipt of the message by performing a HTTP DELETE on the
push message resource. Consequently, an application server cannot rely on receiving
acknowledgement receipts for zero TTL push messages.
</t>
<t>
If the user agent is unavailable, a push message with a zero TTL expires and
is never delivered.
</t>
</section>
<section anchor="urgency" title="Push Message Urgency">
<t>
For a device that is battery-powered, it is often critical that it remains
dormant for extended periods. Radio communication in particular consumes
significant power and limits the length of time that the device can operate.
</t>
<t>
To avoid consuming resources to receive trivial messages, it is helpful
if an application server can communicate the urgency of a message and if the
user agent can request that the push server only forward messages of a specific
urgency.
</t>
<t>
An application server MAY include an Urgency header field in its
request for push message delivery. This header field indicates the
message urgency. The push service MUST NOT forward the Urgency header
field to the user agent. A push message without the Urgency header
field defaults to a value of "normal".
</t>
<t>
A user agent MAY include the Urgency header field when monitoring for
push messages to indicate the lowest urgency of push messages that it
is willing to receive. A push service MUST NOT deliver push messages
with lower urgency than the value indicated by the user agent in its
monitoring request. Push messages of any urgency are delivered to a
user agent that does not include an Urgency header field when
monitoring for messages.
</t>
<figure>
<artwork type="abnf">
<![CDATA[
Urgency = urgency-option
urgency-option = ("very-low" / "low" / "normal" / "high")
]]>
</artwork>
</figure>
<texttable anchor="urgency_values" title="Illustrative Urgency Values">
<preamble>
In order of increasing urgency:
</preamble>
<ttcol width='15%' align='center'>Urgency</ttcol>
<ttcol width='45%' align='left'>Device State</ttcol>
<ttcol width='40%' align='left'>Example Application Scenario</ttcol>
<c>very-low</c>
<c>On power and wifi</c>
<c>Advertisements</c>
<c>low</c>
<c>On either power or wifi</c>
<c>Topic updates</c>
<c>normal</c>
<c>On neither power nor wifi</c>
<c>Chat or Calendar Message</c>
<c>high</c>
<c>Low battery</c>
<c>Incoming phone call or time-sensitive alert</c>
</texttable>
<t>
Multiple values for the Urgency header
field MUST NOT be included in requests; otherwise, the push service
MUST return a 400 (Bad Request) status code.
</t>
</section>
<section anchor="replace" title="Replacing Push Messages">
<t>
A push message that has been stored by the push service can be
replaced with new content. If the user agent is offline during the
time that the push messages are sent, updating a push message avoids
the situation where outdated or redundant messages are sent to the
user agent.
</t>
<t>
Only push messages that have been assigned a topic can be replaced. A
push message with a topic replaces any outstanding push message with
an identical topic.
</t>
<t>
A push message topic is a string carried in a Topic header field.
A topic is used to correlate push messages sent to the same subscription and
does not convey any other semantics.
</t>
<t>
The grammar for the Topic header field uses the <spanx
style="verb">token</spanx> rule defined in <xref target="RFC7230"/>.
</t>
<figure>
<artwork type="abnf">
<![CDATA[
Topic = token
]]>
</artwork>
</figure>
<t>
For use with this protocol, the Topic header field MUST be restricted
to no more than 32 characters from the URL and filename safe Base 64
alphabet <xref target="RFC4648"/>. A push service that receives a request
with a Topic header field that does not meet these constraints MUST return
a 400 (Bad Request) status code to the application server.
</t>
<t>
A push message replacement request creates a new push message resource
and simultaneously deletes any existing message resource that has a
matching topic. If an attempt was made to deliver the deleted push
message, an acknowledgment could arrive at the push service after the
push message has been replaced. Delivery receipts for such deleted
messages SHOULD be suppressed.
</t>
<t>
The replacement request also replaces the stored TTL, Urgency, and any
receipt subscription associated with the previous message in the
matching topic.
</t>
<t>
A push message with a topic that is not shared by an outstanding
message to the same subscription is stored or delivered as normal.
</t>
<figure>
<preamble>
For example, the following message could cause an existing message
to be replaced:
</preamble>
<artwork type="inline"><![CDATA[
POST /push/JzLQ3raZJfFBR0aqvOMsLrt54w4rJUsV HTTP/1.1
Host: push.example.net
TTL: 600
Topic: upd
Content-Type: text/plain;charset=utf8
Content-Length: 36
ZuHSZPKa2b1jtOKLGpWrcrn8cNqt0iVQyroF
]]></artwork>
</figure>
<figure>
<preamble>
If the push service identifies an outstanding push message with a
topic of "upd", then that message resource is deleted. A 201
(Created) response indicates that the push message replacement was
accepted. A URI for the new push message resource that was created
in response to the request is included in the Location header field.
</preamble>
<artwork type="inline"><![CDATA[
HTTP/1.1 201 Created
Date: Thu, 11 Dec 2014 23:57:02 GMT
Location: https://push.example.net/message/qDIYHNcfAIPP_5ITvURr-d6BGt
]]></artwork>
</figure>
<t>
The value of the Topic header field MUST NOT be forwarded to user
agents. Its value is neither encrypted nor authenticated.
</t>
</section>
</section>
<section anchor="monitor-subscription" title="Receiving Push Messages for a Subscription">
<t>
A user agent requests the delivery of new push messages by making a GET
request to a push message subscription resource. The push service does
not respond to this request, it instead uses <xref
target="RFC7540">HTTP/2 server push</xref> to send the
contents of push messages as they are sent by application servers.
</t>
<t>
A user agent MAY include a Urgency header field in its request. The push service MUST
NOT deliver messages with lower urgency than the value of the header field
as defined in the <xref target="urgency_values" format="title"/>.
</t>
<t>
Each push message is pushed as the response to a synthesized GET request
sent in a PUSH_PROMISE. This GET request is made to the push message resource
that was created by the push service when the application server requested
message delivery. The response headers SHOULD provide a URI for the push
resource corresponding to the push message subscription in a link relation
of type "urn:ietf:params:push". The response body is the entity body from
the most recent request sent to the push resource by the application server.
</t>
<figure>
<preamble>
The following example request is made over HTTP/2.
</preamble>
<artwork><![CDATA[
HEADERS [stream 7] +END_STREAM +END_HEADERS
:method = GET
:path = /subscription/LBhhw0OohO-Wl4Oi971UG
:authority = push.example.net
]]></artwork>
</figure>
<figure>
<preamble>
The push service permits the request to remain outstanding. When a
push message is sent by an application server, a server push is generated
in association with the initial request. The response for the server push includes the push
message.
</preamble>
<artwork>
<![CDATA[
PUSH_PROMISE [stream 7; promised stream 4] +END_HEADERS
:method = GET
:path = /message/qDIYHNcfAIPP_5ITvURr-d6BGt
:authority = push.example.net
HEADERS [stream 4] +END_HEADERS
:status = 200
date = Thu, 11 Dec 2014 23:56:56 GMT
last-modified = Thu, 11 Dec 2014 23:56:55 GMT
cache-control = private
link = </push/JzLQ3raZJfFBR0aqvOMsLrt54w4rJUsV>;
rel="urn:ietf:params:push"
content-type = text/plain;charset=utf8
content-length = 36
DATA [stream 4] +END_STREAM
iChYuI3jMzt3ir20P8r_jgRR-dSuN182x7iB
HEADERS [stream 7] +END_STREAM +END_HEADERS
:status = 200
]]>
</artwork>
</figure>
<t>
A user agent can also request the contents of the push message subscription
resource immediately by including a <xref target="RFC7240">Prefer header
field</xref> with a "wait" preference set to "0". In response to this request,
the push service MUST generate a server push for all push messages that have not yet
been delivered.
</t>
<t>
A 204 (No Content) status code with no associated server pushes
indicates that no messages are presently available. This could be
because push messages have expired.
</t>
<section anchor="monitor-set" title="Receiving Push Messages for a Subscription Set">
<t>
There are minor differences between receiving push messages for a subscription and
a subscription set. If a subscription set is available, the user agent SHOULD use the
subscription set to monitor for push messages rather than individual push message
subscriptions.
</t>
<t>
A user agent requests the delivery of new push messages for a collection of
push message subscriptions by making a GET request to a push message subscription
set resource. The push service does not respond to this request, it instead uses
<xref target="RFC7540">HTTP/2 server push</xref> to send the contents of push
messages as they are sent by application servers.
</t>
<t>
A user agent MAY include a Urgency header field in its request. The push service MUST
NOT deliver messages with lower urgency than the value of the header field
as defined in the <xref target="urgency_values" format="title"/>.
</t>
<t>
Each push message is pushed as the response to a synthesized GET request
sent in a PUSH_PROMISE. This GET request is made to the push message resource
that was created by the push service when the application server requested
message delivery. The synthetic request MUST provide a URI for the push resource
corresponding to the push message subscription in a link relation of type
"urn:ietf:params:push". This enables the user agent to differentiate the source
of the message. The response body is the entity body from the most recent request
sent to the push resource by an application server.
</t>
<figure>
<preamble>
The following example request is made over HTTP/2.
</preamble>
<artwork>
<![CDATA[
HEADERS [stream 7] +END_STREAM +END_HEADERS
:method = GET
:path = /subscription-set/4UXwi2Rd7jGS7gp5cuutF8ZldnEuvbOy
:authority = push.example.net
]]>
</artwork>
</figure>
<figure>
<preamble>
The push service permits the request to remain outstanding. When a
push message is sent by an application server, a server push is
generated in association with the initial request. The server push's response includes the push
message.
</preamble>
<artwork>
<![CDATA[
PUSH_PROMISE [stream 7; promised stream 4] +END_HEADERS
:method = GET
:path = /message/qDIYHNcfAIPP_5ITvURr-d6BGt
:authority = push.example.net
HEADERS [stream 4] +END_HEADERS
:status = 200
date = Thu, 11 Dec 2014 23:56:56 GMT
last-modified = Thu, 11 Dec 2014 23:56:55 GMT
link = </push/JzLQ3raZJfFBR0aqvOMsLrt54w4rJUsV>;
rel="urn:ietf:params:push"
cache-control = private
content-type = text/plain;charset=utf8
content-length = 36
DATA [stream 4] +END_STREAM
iChYuI3jMzt3ir20P8r_jgRR-dSuN182x7iB
HEADERS [stream 7] +END_STREAM +END_HEADERS
:status = 200
]]>
</artwork>
</figure>
<t>
A user agent can request the contents of the push message subscription
set resource immediately by including a <xref target="RFC7240">Prefer header
field</xref> with a "wait" preference set to "0". In response to this request,
the push service MUST generate a server push for all push messages that have not
yet been delivered.
</t>
<t>
A 204 (No Content) status code with no associated server pushes
indicates that no messages are presently available. This could be
because push messages have expired.
</t>
</section>
<section anchor="acknowledge_message"
title="Acknowledging Push Messages">
<t>
To ensure that a push message is properly delivered to the user agent
at least once, the user agent MUST acknowledge receipt of the message
by performing a HTTP DELETE on the push message resource.
</t>
<figure>
<artwork type="inline">
<![CDATA[
DELETE /message/qDIYHNcfAIPP_5ITvURr-d6BGt HTTP/1.1
Host: push.example.net
]]>
</artwork>
</figure>
<t>
If the push service receives the acknowledgement and the application
has requested a delivery receipt, the push service MUST return a 204 (No Content)
response to the application server monitoring the receipt subscription.
</t>
<t>
If the push service does not receive the acknowledgement within a
reasonable amount of time, then the message is considered to be not yet
delivered. The push service SHOULD continue to retry delivery of the message
until its advertised expiration.
</t>
<t>
The push service MAY cease to retry delivery of the message prior to its
advertised expiration due to scenarios such as an unresponsive user agent or
operational constraints. If the application has requested a delivery receipt,
then the push service MUST return a 410 (Gone) response to the application server
monitoring the receipt subscription.
</t>