diff --git a/lib/utilities/collectResponseHeaders.js b/lib/utilities/collectResponseHeaders.js index 99f3b6bba3..6969b3cb8c 100644 --- a/lib/utilities/collectResponseHeaders.js +++ b/lib/utilities/collectResponseHeaders.js @@ -91,7 +91,7 @@ function collectResponseHeaders(objectMD, corsHeaders, versioningCfg, returnTagC } if (objectMD.replicationInfo) { const { isReplica, status } = objectMD.replicationInfo; - if (isReplica) { + if (isReplica || status === 'REPLICA') { const hasReplicated = !status || status === 'COMPLETED'; responseMetaHeaders['x-amz-replication-status'] = hasReplicated ? 'REPLICA' : status; responseMetaHeaders['x-amz-meta-scal-replica'] = 'true'; diff --git a/package.json b/package.json index 5fb4b68aea..a79cc3e702 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@zenko/cloudserver", - "version": "9.4.3", + "version": "9.4.4", "description": "Zenko CloudServer, an open-source Node.js implementation of a server handling the Amazon S3 protocol", "main": "index.js", "engines": { diff --git a/tests/unit/utils/collectResponseHeaders.js b/tests/unit/utils/collectResponseHeaders.js index 5dd59103ba..75e26e66f2 100644 --- a/tests/unit/utils/collectResponseHeaders.js +++ b/tests/unit/utils/collectResponseHeaders.js @@ -17,6 +17,13 @@ describe('Middleware: Collect Response Headers', () => { assert.deepStrictEqual(headers['x-amz-meta-scal-replica'], 'true'); }); + it('should mark a replica written without the isReplica flag', () => { + const objectMD = { replicationInfo: { status: 'REPLICA' } }; + const headers = collectResponseHeaders(objectMD); + assert.deepStrictEqual(headers['x-amz-replication-status'], 'REPLICA'); + assert.deepStrictEqual(headers['x-amz-meta-scal-replica'], 'true'); + }); + it('should default to REPLICA when isReplica is true and status is absent', () => { const objectMD = { replicationInfo: { isReplica: true } }; const headers = collectResponseHeaders(objectMD);