Skip to content

Commit

Permalink
fix: revert header change (#161)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-fenster authored Aug 28, 2019
1 parent f49e0e6 commit b0f6a8b
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 23 deletions.
8 changes: 1 addition & 7 deletions src/gaxios.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
16 changes: 0 additions & 16 deletions test/test.getch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit b0f6a8b

Please sign in to comment.