mirror of
https://github.com/Kong/insomnia
synced 2024-11-08 14:49:53 +00:00
* Clear Content-Type when selecting 'No Body' * Remove CONTENT_TYPE_NO_BODY and simplify filter
This commit is contained in:
parent
605cb90753
commit
2b3591f6e4
@ -119,7 +119,7 @@ describe('updateMimeType()', async () => {
|
|||||||
expect(newRequest.headers).toEqual([{ name: 'content-tYPE', value: 'text/html' }]);
|
expect(newRequest.headers).toEqual([{ name: 'content-tYPE', value: 'text/html' }]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('keeps content-type', async () => {
|
it('removes existing content-type when set to null (i.e. no body)', async () => {
|
||||||
const request = await models.request.create({
|
const request = await models.request.create({
|
||||||
name: 'My Request',
|
name: 'My Request',
|
||||||
parentId: 'fld_1',
|
parentId: 'fld_1',
|
||||||
@ -129,7 +129,7 @@ describe('updateMimeType()', async () => {
|
|||||||
|
|
||||||
const newRequest = await models.request.updateMimeType(request, null);
|
const newRequest = await models.request.updateMimeType(request, null);
|
||||||
expect(newRequest.body).toEqual({});
|
expect(newRequest.body).toEqual({});
|
||||||
expect(newRequest.headers).toEqual([{ name: 'content-tYPE', value: 'application/json' }]);
|
expect(newRequest.headers).toEqual([]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('uses saved body when provided', async () => {
|
it('uses saved body when provided', async () => {
|
||||||
|
@ -282,7 +282,9 @@ export function updateMimeType(
|
|||||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //
|
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //
|
||||||
|
|
||||||
const hasBody = typeof mimeType === 'string';
|
const hasBody = typeof mimeType === 'string';
|
||||||
if (!hasBody || mimeType === CONTENT_TYPE_OTHER) {
|
if (!hasBody) {
|
||||||
|
headers = headers.filter(h => h !== contentTypeHeader);
|
||||||
|
} else if (mimeType === CONTENT_TYPE_OTHER) {
|
||||||
// Leave headers alone
|
// Leave headers alone
|
||||||
} else if (mimeType && contentTypeHeader && !leaveContentTypeAlone) {
|
} else if (mimeType && contentTypeHeader && !leaveContentTypeAlone) {
|
||||||
contentTypeHeader.value = contentTypeHeaderValue;
|
contentTypeHeader.value = contentTypeHeaderValue;
|
||||||
|
Loading…
Reference in New Issue
Block a user