mirror of
https://github.com/floci-io/floci.git
synced 2026-11-23 22:11:36 -05:00
fix(s3): omit whole-object checksum headers on range responses (#1040)
PR #923 routed handleRangeRequest through appendObjectHeaders so 206 partial-content responses would pick up stored headers and response-* overrides. That also pulled in appendChecksumHeaders, which emits obj.getChecksum() — the whole-object checksum — onto partial responses. SDKs that validate the checksum against the received body then fail, e.g. a `bytes=4-7` GET returns the full-object CRC64NVME and the AWS CLI reports: Expected checksum CRSFynAYcw4= did not match calculated checksum: LQYlQwQYKmA= Real S3 does not return whole-object checksum headers on ranged responses. Add an includeChecksum flag to appendObjectHeaders (defaults true for the existing GET/HEAD callers) and pass false from handleRangeRequest. The override + restored-header improvements from #923 are unaffected. Reported by @dwhjames on #923.
This commit is contained in:
1 parent
ad02786b8a
commit
25d6988950
2 files changed
+31
-2
No files matched your search
@@ -653,7 +653,8 @@ public class S3Controller {
|
||||
if (obj.getVersionId() != null) {
|
||||
resp.header("x-amz-version-id", obj.getVersionId());
|
||||
}
|
||||
appendObjectHeaders(resp, obj, overrides);
|
||||
// includeChecksum=false: the stored checksum covers the whole object, not this range.
|
||||
appendObjectHeaders(resp, obj, overrides, false);
|
||||
return resp.build();
|
||||
}
|
||||
|
||||
@@ -1547,6 +1548,14 @@ public class S3Controller {
|
||||
}
|
||||
|
||||
private void appendObjectHeaders(Response.ResponseBuilder resp, S3Object obj, ResponseHeaderOverrides overrides) {
|
||||
appendObjectHeaders(resp, obj, overrides, true);
|
||||
}
|
||||
|
||||
// includeChecksum must be false for partial (206) responses: obj.getChecksum() is the
|
||||
// whole-object checksum, which does not match the range bytes returned. SDKs that
|
||||
// validate it against the received body fail. Real S3 omits it on ranged responses.
|
||||
private void appendObjectHeaders(Response.ResponseBuilder resp, S3Object obj, ResponseHeaderOverrides overrides,
|
||||
boolean includeChecksum) {
|
||||
if (obj.getStorageClass() != null) {
|
||||
resp.header("x-amz-storage-class", obj.getStorageClass());
|
||||
}
|
||||
@@ -1576,7 +1585,9 @@ public class S3Controller {
|
||||
resp.header("x-amz-meta-" + entry.getKey(), entry.getValue());
|
||||
}
|
||||
}
|
||||
appendChecksumHeaders(resp, obj.getChecksum());
|
||||
if (includeChecksum) {
|
||||
appendChecksumHeaders(resp, obj.getChecksum());
|
||||
}
|
||||
appendLockHeaders(resp, obj);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user