Skip to content

Commit 04bd276

Browse files
authored
Merge pull request #93 from braid-org/optional-forget
Removed the ability for subscriptions to outlive connections
2 parents d882d35 + 330948c commit 04bd276

File tree

1 file changed

+57
-44
lines changed

1 file changed

+57
-44
lines changed

draft-toomim-httpbis-braid-http-03.txt

Lines changed: 57 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -149,9 +149,9 @@ Table of Contents
149149

150150
2. Subscriptions (Section 3)
151151

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.
155155

156156
3. Range Patches [RANGE-PATCH]
157157

@@ -482,19 +482,15 @@ Table of Contents
482482

483483
Subscribe
484484
or Subscribe: keep-alive
485-
or Subscribe: keep-alive=<seconds>
486485

487486
If a server implements Subscribe, it MUST include a Subscribe header
488487
in its response. The server then SHOULD keep the connection open,
489488
and send updates over it.
490489

491490
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.
498494

499495

500496
3.2. Sending multiple updates per GET
@@ -516,50 +512,67 @@ Table of Contents
516512

517513
3.3. Continuing a Subscription
518514

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.
529517

530518
When the client reconnects, it may specify the most recent versions
531519
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"}}] | |
533541

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>
538543

544+
Reconnection request:
539545

540-
3.4. Ending a Subscription
546+
GET /chat
547+
Subscribe: keep-alive
548+
Parents: "ej4lhb9z78"
541549

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:
545551

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"}] | |
554566

555567

556-
3.5. Signaling "all caught up"
568+
3.4. Signaling "all caught up"
557569

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.
563576

564577

565578
Request:
@@ -583,7 +596,7 @@ Table of Contents
583596
"author": {"link": "/user/tommy"}}] V
584597
<-- Now caught up
585598

586-
3.6. Errors
599+
3.5. Errors
587600

588601
If a server has dropped the history that a client requests, the
589602
server can return a 410 GONE response, to tell the client "sorry, I

0 commit comments

Comments
 (0)