Skip to content

feat/streams conditional get#549

Open
MerlinTheWhiz wants to merge 2 commits into
Fluxora-Org:mainfrom
MerlinTheWhiz:feat/streams-conditional-get
Open

feat/streams conditional get#549
MerlinTheWhiz wants to merge 2 commits into
Fluxora-Org:mainfrom
MerlinTheWhiz:feat/streams-conditional-get

Conversation

@MerlinTheWhiz

@MerlinTheWhiz MerlinTheWhiz commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

PR Summary

Closes #484

Description

GET /api/streams/:id already computed and set an ETag header (streamEntityTag(metadata)), but never read the inbound If-None-Match request header. This meant well-behaved HTTP caches and polling clients always received a full 200 body even when their cached representation was still valid.

This PR implements conditional GET support per RFC 7232 §3.2, allowing clients to skip re-downloading unchanged stream bodies.

Changes

File Change
src/routes/streams.ts Added matchesIfNoneMatch() helper (weak comparison per RFC 7232, supporting *, comma-separated lists, and W/ prefix). Modified GET /:id handler to check If-None-Match after computing the ETag and return 304 Not Modified with no body on match.
src/openapi/spec.ts Documented the 304 response with ETag and Last-Modified headers, plus the If-None-Match request header on GET /api/streams/{id}.
tests/routes/streams.test.ts 8 new tests covering: exact ETag match, * wildcard, comma-separated lists, non-matching tag, absent header, 304 header presence, empty body on 304, and 200 envelope shape preservation.

Acceptance criteria

  • Matching If-None-Match returns 304 with no body and the ETag header
  • Non-matching / absent If-None-Match returns the existing 200 envelope
  • * and comma-separated tag lists are handled
  • Weak comparison (RFC 7232) — W/ prefix is stripped before comparing
  • OpenAPI documents the 304 response

Security notes

The ETag is derived from server-side metadata only (id + updated_at), using a SHA-256 hash. No client-controlled input flows into the tag. The 304 response leaks no body content.

@drips-wave

drips-wave Bot commented Jun 27, 2026

Copy link
Copy Markdown

@MerlinTheWhiz Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support conditional GET on GET /api/streams/:id via If-None-Match and return 304 in src/routes/streams.ts

1 participant