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)