Skip to content

Commit 9fbccb3

Browse files
committed
fix: don't return 412 for if-none-match failures
Closes nodejs/build#4030 Signed-off-by: flakey5 <[email protected]>
1 parent d936d0c commit 9fbccb3

File tree

2 files changed

+4
-7
lines changed

2 files changed

+4
-7
lines changed

src/providers/r2Provider.ts

+3-6
Original file line numberDiff line numberDiff line change
@@ -180,13 +180,10 @@ function areConditionalHeadersPresent(
180180

181181
const { conditionalHeaders } = options;
182182

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

192189
function determineHttpStatusCode(
@@ -208,7 +205,7 @@ function determineHttpStatusCode(
208205
return 412;
209206
}
210207

211-
// We weren't given a body and preconditions succeeded.
208+
// We weren't given a body
212209
return 304;
213210
}
214211

tests/e2e/file.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ describe('File Tests', () => {
160160
'if-none-match': originalETag,
161161
},
162162
});
163-
assert(res.status === 304 || res.status === 412);
163+
assert(res.status === 304);
164164
});
165165

166166
it('handles range header correctly', async () => {

0 commit comments

Comments
 (0)