fix: add ETag and headers to 304 Not Modified responses
Deploy FileDrop / deploy (push) Failing after 15s
Deploy FileDrop / deploy (push) Failing after 15s
AWS SDK requires ETag header in 304 responses. Without it, the SDK throws UnknownError despite receiving a valid 304 status code. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -489,7 +489,10 @@ const handleGetObject = async (
|
||||
}
|
||||
const ifNoneMatch = headers['if-none-match'];
|
||||
if (ifNoneMatch && ifNoneMatch === etag) {
|
||||
return new Response(null, { status: 304 });
|
||||
return new Response(null, { status: 304, headers: s3Headers(reqId, {
|
||||
etag, 'content-type': file.mimeType, 'content-length': String(file.sizeBytes),
|
||||
'last-modified': lastModified.toUTCString(), 'x-amz-version-id': 'null',
|
||||
}) });
|
||||
}
|
||||
|
||||
// H3: Conditional headers — If-Modified-Since / If-Unmodified-Since
|
||||
@@ -498,7 +501,10 @@ const handleGetObject = async (
|
||||
if (ifModifiedSince) {
|
||||
const since = new Date(ifModifiedSince);
|
||||
if (!Number.isNaN(since.getTime()) && lastModified.getTime() <= since.getTime()) {
|
||||
return new Response(null, { status: 304 });
|
||||
return new Response(null, { status: 304, headers: s3Headers(reqId, {
|
||||
etag, 'content-type': file.mimeType, 'content-length': String(file.sizeBytes),
|
||||
'last-modified': lastModified.toUTCString(), 'x-amz-version-id': 'null',
|
||||
}) });
|
||||
}
|
||||
}
|
||||
const ifUnmodifiedSince = headers['if-unmodified-since'];
|
||||
@@ -739,7 +745,10 @@ const handleHeadObject = async (
|
||||
}
|
||||
const ifNoneMatch = headers['if-none-match'];
|
||||
if (ifNoneMatch && ifNoneMatch === etag) {
|
||||
return new Response(null, { status: 304 });
|
||||
return new Response(null, { status: 304, headers: s3Headers(reqId, {
|
||||
etag, 'content-type': file.mimeType, 'content-length': String(file.sizeBytes),
|
||||
'last-modified': lastModified.toUTCString(), 'x-amz-version-id': 'null',
|
||||
}) });
|
||||
}
|
||||
|
||||
// H3: Conditional headers for HEAD — If-Modified-Since / If-Unmodified-Since
|
||||
@@ -748,7 +757,10 @@ const handleHeadObject = async (
|
||||
if (ifModifiedSince) {
|
||||
const since = new Date(ifModifiedSince);
|
||||
if (!Number.isNaN(since.getTime()) && lastModified.getTime() <= since.getTime()) {
|
||||
return new Response(null, { status: 304 });
|
||||
return new Response(null, { status: 304, headers: s3Headers(reqId, {
|
||||
etag, 'content-type': file.mimeType, 'content-length': String(file.sizeBytes),
|
||||
'last-modified': lastModified.toUTCString(), 'x-amz-version-id': 'null',
|
||||
}) });
|
||||
}
|
||||
}
|
||||
const ifUnmodifiedSince = headers['if-unmodified-since'];
|
||||
|
||||
Reference in New Issue
Block a user