diff --git a/plugins/caches.js b/plugins/caches.js index f69949d..bfcc1ba 100644 --- a/plugins/caches.js +++ b/plugins/caches.js @@ -100,8 +100,8 @@ exports.plugin = { response = h.response(Buffer.from(value.c.data)); response.headers = value.h; } else { - response = h.response(value); - response.headers['content-type'] = 'application/zip'; + response = h.response(Buffer.from(value)); + response.headers['content-type'] = 'text/plain'; } if (strategyConfig.plugin !== 's3') { @@ -210,10 +210,10 @@ exports.plugin = { } }); - // For application/zip, upload it as Buffer + // For text/plain, upload it as Buffer // Otherwise, catbox-s3 will try to JSON.stringify (https://github.com/fhemberger/catbox-s3/blob/master/lib/index.js#L236) // and might create issue on large payload - if (contents.h['content-type'] === 'application/zip') { + if (contents.h['content-type'] === 'text/plain') { value = contents.c; } diff --git a/test/plugins/caches.test.js b/test/plugins/caches.test.js index 10e671e..9dfe13f 100644 --- a/test/plugins/caches.test.js +++ b/test/plugins/caches.test.js @@ -263,7 +263,7 @@ describe('events plugin test', () => { payload: 'THIS IS A TEST', headers: { 'x-foo': 'bar', - 'content-type': 'application/zip', + 'content-type': 'text/plain', ignore: 'true' }, credentials: { @@ -321,7 +321,7 @@ describe('events plugin test', () => { }); }); - it('saves a cache without headers for application/zip type', async () => { + it('saves a cache without headers for text/plain type', async () => { options.url = `/caches/events/${mockEventID}/foo`; const putResponse = await server.inject(options); @@ -336,7 +336,7 @@ describe('events plugin test', () => { } }).then((getResponse) => { assert.equal(getResponse.statusCode, 200); - assert.equal(getResponse.headers['content-type'], 'application/zip'); + assert.equal(getResponse.headers['content-type'], 'text/plain; charset=utf-8'); assert.isNotOk(getResponse.headers['x-foo']); assert.isNotOk(getResponse.headers.ignore); assert.equal(getResponse.result, 'THIS IS A TEST'); @@ -373,7 +373,7 @@ describe('events plugin test', () => { payload: 'THIS IS A TEST', headers: { 'x-foo': 'bar', - 'content-type': 'application/zip', + 'content-type': 'text/plain', ignore: 'true' }, credentials: { @@ -431,7 +431,7 @@ describe('events plugin test', () => { }); }); - it('saves a cache without headers for application/zip type', async () => { + it('saves a cache without headers for text/plain type', async () => { options.url = `/caches/jobs/${mockJobID}/foo`; const putResponse = await server.inject(options); @@ -446,7 +446,7 @@ describe('events plugin test', () => { } }).then((getResponse) => { assert.equal(getResponse.statusCode, 200); - assert.equal(getResponse.headers['content-type'], 'application/zip'); + assert.equal(getResponse.headers['content-type'], 'text/plain; charset=utf-8'); assert.isNotOk(getResponse.headers['x-foo']); assert.isNotOk(getResponse.headers.ignore); assert.equal(getResponse.result, 'THIS IS A TEST');