Skip to content

fix: don't return 412 for if-none-match failures #321

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions src/providers/r2Provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,13 +180,10 @@ function areConditionalHeadersPresent(

const { conditionalHeaders } = options;

// Only check for if-none-match and if-unmodified-since because the docs said
// Only check for if-unmodified-since because the docs said
// so, also what nginx does from my experiments
// https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/412
return (
conditionalHeaders.ifNoneMatch !== undefined ||
conditionalHeaders.ifUnmodifiedSince !== undefined
);
return conditionalHeaders.ifUnmodifiedSince !== undefined;
}

function determineHttpStatusCode(
Expand All @@ -208,7 +205,7 @@ function determineHttpStatusCode(
return 412;
}

// We weren't given a body and preconditions succeeded.
// We weren't given a body
return 304;
}

Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/file.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ describe('File Tests', () => {
'if-none-match': originalETag,
},
});
assert(res.status === 304 || res.status === 412);
assert(res.status === 304);
});

it('handles range header correctly', async () => {
Expand Down
Loading