Live push: since is a plain seq; only Last-Event-ID carries a tag (#175 follow-up 1)
The stream split <seq>.<tag> on whichever of Last-Event-ID or since it read, so since=<seq>.<tag> still put the row's digest in the query string, which access logs keep. Only Last-Event-ID (a header) is split now; since is read as a plain seq, and since=5.x is a 400, as parseSince answers. TestPushSinceIsAPlainSeq: since=1.<tag> answered 200 before, 400 now.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2 files changed,
+29
−4
internal/docs/push_test.go+20 −0internal/docs/stream.go+9 −4
diff --git a/internal/docs/push_test.go b/internal/docs/push_test.go| index 06caf95..568f278 100644 |
| --- a/internal/docs/push_test.go |
| +++ b/internal/docs/push_test.go |
| @@ -1462,3 +1462,23 @@ func TestTeamGuestStreamAsksTheRosterNothing(t *testing.T) { |
| t.Fatalf("a guest's stream asked the roster %d times for three deliveries", n) |
| } |
| } |
| + |
| +// Follow-up to #175: since is a plain seq, as parseSince reads it. A tag |
| +// there (since=<seq>.<tag>) would put the row's digest back in the query |
| +// string; it is a 400. Only Last-Event-ID carries <seq>.<tag>. |
| +func TestPushSinceIsAPlainSeq(t *testing.T) { |
| + f := newPushFixture(t, pushOn()) |
| + f.post(f.cookies, f.update(1, "one"), "") |
| + req, _ := http.NewRequest(http.MethodGet, f.srv.URL+"/d/"+f.doc.Sqid+"/stream?push=1&since=1.0000000000000000", nil) |
| + for _, c := range f.cookies { |
| + req.AddCookie(c) |
| + } |
| + res, err := f.srv.Client().Do(req) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + res.Body.Close() |
| + if res.StatusCode != http.StatusBadRequest { |
| + t.Fatalf("since=<seq>.<tag> answered %d, want 400", res.StatusCode) |
| + } |
| +} |
diff --git a/internal/docs/stream.go b/internal/docs/stream.go| index d3a3947..f37aaca 100644 |
| --- a/internal/docs/stream.go |
| +++ b/internal/docs/stream.go |
| @@ -167,14 +167,19 @@ func (h *handlers) stream(w http.ResponseWriter, r *http.Request) { |
| // tag is an unkeyed digest of the row (#175 approval, finding 6). |
| start, resume, tag := current, false, "" |
| if push { |
| - raw := r.Header.Get("Last-Event-ID") |
| - if raw == "" { |
| + raw, rawTag := r.Header.Get("Last-Event-ID"), "" |
| + if raw != "" { |
| + // Only Last-Event-ID carries <seq>.<tag>: it is a header, and it |
| + // is what EventSource sends back from a frame's id. |
| + raw, rawTag, _ = strings.Cut(raw, ".") |
| + } else { |
| + // since is a plain seq, as parseSince reads it: since=<seq>.<tag> |
| + // would put the tag back in the query string, and is a 400. |
| raw = r.URL.Query().Get("since") |
| tag = r.Header.Get("Docs-Seq-Tag") |
| } |
| if raw != "" { |
| - seqText, rawTag, _ := strings.Cut(raw, ".") |
| - n, err := strconv.ParseInt(seqText, 10, 64) |
| + n, err := strconv.ParseInt(raw, 10, 64) |
| if err != nil || n < 0 { |
| http.Error(w, rastrillo.T(r, "docs.error.badsince"), http.StatusBadRequest) |
| return |