From b0f6a8baed30f84b8ddd8ef9657d6ca5534097fd Mon Sep 17 00:00:00 2001 From: Alexander Fenster Date: Wed, 28 Aug 2019 08:49:13 -0700 Subject: [PATCH] fix: revert header change (#161) --- src/gaxios.ts | 8 +------- test/test.getch.ts | 16 ---------------- 2 files changed, 1 insertion(+), 23 deletions(-) diff --git a/src/gaxios.ts b/src/gaxios.ts index 8c6bb0fd..5541e56a 100644 --- a/src/gaxios.ts +++ b/src/gaxios.ts @@ -187,13 +187,7 @@ export class Gaxios { opts.body = opts.data; } else if (typeof opts.data === 'object') { opts.body = JSON.stringify(opts.data); - if ( - !Object.keys(opts.headers).some((key: string) => - key.match(/^content-type$/i) - ) - ) { - opts.headers['Content-Type'] = 'application/json'; - } + opts.headers['Content-Type'] = 'application/json'; } else { opts.body = opts.data; } diff --git a/test/test.getch.ts b/test/test.getch.ts index da47708d..3af418b8 100644 --- a/test/test.getch.ts +++ b/test/test.getch.ts @@ -307,22 +307,6 @@ describe('🎏 data handling', () => { assert.deepStrictEqual(res.data, {}); }); - it('should allow to override content-type for object request', async () => { - const body = {hello: '🌎'}; - const scope = nock(url) - .matchHeader('content-type', 'application/octet-stream') - .post('/', JSON.stringify(body)) - .reply(200, {}); - const res = await request({ - url, - method: 'POST', - data: body, - headers: {'content-type': 'application/octet-stream'}, - }); - scope.done(); - assert.deepStrictEqual(res.data, {}); - }); - it('should return stream if asked nicely', async () => { const body = {hello: '🌎'}; const scope = nock(url)