Skip to content

fix: treat If-Match: * as satisfied when etag is disabled - #317

Merged
blakeembrey merged 1 commit into
pillarjs:masterfrom
yxshee:fix/if-match-star-without-etag
Nov 10, 2026
Merged

blakeembrey merged 1 commit into
pillarjs:masterfrom
yxshee:fix/if-match-star-without-etag

Conversation

@yxshee

@yxshee yxshee commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

With etag: false, a request carrying If-Match: * for a file that exists gets 412 Precondition Failed. RFC 9110 section 13.1.1 says * is true whenever the server has a current representation, so it doesn't depend on an ETag being present. With the default etag: true the same request already gets 200.

http.createServer((req, res) => send(req, req.url, { root: 'test/fixtures', etag: false }).pipe(res)).listen(3000)
// curl -i -H 'If-Match: *' localhost:3000/name.txt
// actual: 412 Precondition Failed    expected: 200 OK, body "tobi"

The fix checks for * before looking at the ETag header, so a missing ETag only fails the precondition when the client lists actual entity tags.

I added a test under "where If-Match is set" that makes this request with etag: false. On master it fails with Error: expected 200 "OK", got 412 "Precondition Failed". With the fix all 140 tests pass (npm test and npm run test-ci), and npm run lint is clean.

@blakeembrey
blakeembrey merged commit 4d246b3 into pillarjs:master Nov 10, 2026
21 of 22 checks passed
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.

2 participants