@@ -149,9 +149,9 @@ Table of Contents
149
149
150
150
2. Subscriptions (Section 3)
151
151
152
- A Subscribe header can be added to GET requests, which promises
153
- to push all future versions to the client, until the client says
154
- forGET .
152
+ A Subscribe header can be added to GET requests. The server
153
+ responds by pushing future versions to the client while the
154
+ request is open .
155
155
156
156
3. Range Patches [RANGE-PATCH]
157
157
@@ -482,19 +482,15 @@ Table of Contents
482
482
483
483
Subscribe
484
484
or Subscribe: keep-alive
485
- or Subscribe: keep-alive=<seconds>
486
485
487
486
If a server implements Subscribe, it MUST include a Subscribe header
488
487
in its response. The server then SHOULD keep the connection open,
489
488
and send updates over it.
490
489
491
490
In general, a server that implements subscriptions promises to keep
492
- its subscribed clients up-to-date by sending changes until the client
493
- closes the subscription. A subscription is different from a GET
494
- connection (e.g. a TCP connection, or HTTP/2 stream). If a client
495
- requests "Subscribe: keep-alive", then the subscription will be
496
- remembered even after the GET connection closes. A subscription can
497
- be resumed by the client issuing another GET with a Subscribe header.
491
+ its subscribed clients up-to-date by sending changes until the
492
+ connection is closed. Once closed, a subscription can be resumed by
493
+ the client issuing a subsequent GET request on the same document.
498
494
499
495
500
496
3.2. Sending multiple updates per GET
@@ -516,50 +512,67 @@ Table of Contents
516
512
517
513
3.3. Continuing a Subscription
518
514
519
- Even if a connection closes, a subscription might still be active.
520
- If a server's response headers for a connection contained:
521
-
522
- Subscribe: keep-alive
523
- or Subscribe: keep-alive=<seconds>
524
-
525
- Then the server SHOULD keep the subscription open even after the
526
- connection closes. This means that the server promises to keep
527
- enough history to merge with the client when the client comes back
528
- online.
515
+ Once closed, a braid subscription may be restarted by the client
516
+ issuing a new subscription request.
529
517
530
518
When the client reconnects, it may specify the most recent versions
531
519
it saw from the server using the Parents header. This tells the
532
- server which versions of state to catch it up from.
520
+ server which versions & patches need to be sent, so the client and
521
+ server's document state will converge.
522
+
523
+ For example:
524
+
525
+ Initial request:
526
+
527
+ GET /chat
528
+ Subscribe: keep-alive
529
+
530
+ Initial response:
531
+
532
+ HTTP/1.1 209 Subscription
533
+ Subscribe: keep-alive
534
+
535
+ Version: "ej4lhb9z78" | Version
536
+ Content-Type: application/json |
537
+ Content-Length: 64 |
538
+ |
539
+ [{"text": "Hi, everyone!", | | Body
540
+ "author": {"link": "/user/tommy"}}] | |
533
541
534
- The server can suggest how long it will wait for the client by
535
- responding with Subscribe: keep-alive=<seconds>. A server should
536
- wait at least <seconds> after a connection closes before dropping the
537
- subscription, and clearing its history.
542
+ <Client disconnects>
538
543
544
+ Reconnection request:
539
545
540
- 3.4. Ending a Subscription
546
+ GET /chat
547
+ Subscribe: keep-alive
548
+ Parents: "ej4lhb9z78"
541
549
542
- Servers and clients MAY drop a subscription at any time, no matter
543
- the value of keep-alive. A client may reconnect by issuing a new GET
544
- request with a new Subscribe header.
550
+ Reconnection response:
545
551
546
- If a subscription is set to keep-alive, then closing the TCP/QUIC
547
- connection won't end the subscription. Thus a client needs a way to
548
- explicitly end the subscription. In HTTP/1, this is by sending the
549
- text "forGET\n" over the TCP connection. In HTTP/2, this is by
550
- issuing a CLOSE event to the GET request's stream. Alternatively,
551
- since today's web browsers do not support sending extra text after a
552
- request body, the client can issue a fresh request specified as a
553
- FORGET method.
552
+ HTTP/1.1 209 Subscription
553
+ Subscribe: keep-alive
554
+
555
+ Version: "g09ur8z74r" | Version
556
+ Parents: "ej4lhb9z78" |
557
+ Content-Type: application/json |
558
+ Merge-Type: sync9 |
559
+ Patches: 1 |
560
+ |
561
+ Content-Length: 53 | | Patch
562
+ Content-Range: json=.messages[1:1] | |
563
+ | |
564
+ [{"text": "Yo!", | |
565
+ "author": {"link": "/user/yobot"}] | |
554
566
555
567
556
- 3.5 . Signaling "all caught up"
568
+ 3.4 . Signaling "all caught up"
557
569
558
- When starting a subscription, the server can indicate which version
559
- is current by specifying a "Current-Versions" header before starting
560
- the stream of versions. This should contain the frontier of time,
561
- aka the leaves of the currently-known time DAG. The client can use
562
- this information to determine when it has caught up with the server.
570
+ When starting or resuming a subscription, the server can indicate
571
+ which version is current by specifying a "Current-Versions" header
572
+ before starting the stream of versions. This should contain the
573
+ frontier of time, aka the leaves of the currently-known time DAG. The
574
+ client can use this information to determine when it has caught up
575
+ with the server.
563
576
564
577
565
578
Request:
@@ -583,7 +596,7 @@ Table of Contents
583
596
"author": {"link": "/user/tommy"}}] V
584
597
<-- Now caught up
585
598
586
- 3.6 . Errors
599
+ 3.5 . Errors
587
600
588
601
If a server has dropped the history that a client requests, the
589
602
server can return a 410 GONE response, to tell the client "sorry, I
0 commit comments