Skip to content
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
5 changes: 1 addition & 4 deletions lib/utilities/collectResponseHeaders.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,7 @@ function collectResponseHeaders(objectMD, corsHeaders, versioningCfg,
responseMetaHeaders['x-amz-replication-status'] =
objectMD.replicationInfo.status;
}
if (objectMD.replicationInfo &&
// Use storageType to determine if user metadata is needed.
objectMD.replicationInfo.storageType &&
Array.isArray(objectMD.replicationInfo.backends)) {
if (Array.isArray(objectMD?.replicationInfo?.backends)) {
objectMD.replicationInfo.backends.forEach(backend => {
const { status, site, dataStoreVersionId } = backend;
responseMetaHeaders[`x-amz-meta-${site}-replication-status`] =
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@zenko/cloudserver",
"version": "9.1.0-preview.1",
"version": "9.1.0",
"description": "Zenko CloudServer, an open-source Node.js implementation of a server handling the Amazon S3 protocol",
"main": "index.js",
"engines": {
Expand Down
20 changes: 20 additions & 0 deletions tests/unit/utils/collectResponseHeaders.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,26 @@ describe('Middleware: Collect Response Headers', () => {
assert.deepStrictEqual(headers['x-amz-replication-status'], 'REPLICA');
});

it('should set the replication status of each site', () => {
const objectMD = {
replicationInfo: {
status: 'COMPLETED',
backends: [
{ site: 'us-east-1', status: 'COMPLETED', dataStoreVersionId: '123' },
{ site: 'us-west-2', status: 'COMPLETED', dataStoreVersionId: '' },
],
},
};
const headers = collectResponseHeaders(objectMD);
assert.deepStrictEqual(headers['x-amz-replication-status'], 'COMPLETED');
assert.deepStrictEqual(headers['x-amz-meta-us-east-1-replication-status'],
'COMPLETED');
assert.deepStrictEqual(headers['x-amz-meta-us-east-1-version-id'], '123');
assert.deepStrictEqual(headers['x-amz-meta-us-west-2-replication-status'],
'COMPLETED');
assert.deepStrictEqual(headers['x-amz-meta-us-west-2-version-id'], undefined);
});

[
{ md: { replicationInfo: null }, test: 'when config is not set' },
{ md: {}, test: 'for older objects' },
Expand Down
Loading