feat/streams conditional get#549
Open
MerlinTheWhiz wants to merge 2 commits into
Open
Conversation
|
@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! 🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Summary
Closes #484
Description
GET /api/streams/:idalready computed and set an ETag header (streamEntityTag(metadata)), but never read the inboundIf-None-Matchrequest 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
src/routes/streams.tsmatchesIfNoneMatch()helper (weak comparison per RFC 7232, supporting*, comma-separated lists, andW/prefix). Modified GET/:idhandler to checkIf-None-Matchafter computing the ETag and return 304 Not Modified with no body on match.src/openapi/spec.ts304response withETagandLast-Modifiedheaders, plus theIf-None-Matchrequest header on GET/api/streams/{id}.tests/routes/streams.test.ts*wildcard, comma-separated lists, non-matching tag, absent header, 304 header presence, empty body on 304, and 200 envelope shape preservation.Acceptance criteria
If-None-Matchreturns 304 with no body and theETagheaderIf-None-Matchreturns the existing 200 envelope*and comma-separated tag lists are handledW/prefix is stripped before comparingSecurity 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.