diff --git a/app/network/__tests__/network.test.js b/app/network/__tests__/network.test.js index c79c0c2a5..300fb24a7 100644 --- a/app/network/__tests__/network.test.js +++ b/app/network/__tests__/network.test.js @@ -90,6 +90,55 @@ describe('actuallySend()', () => { }); }); + it('sends a urlencoded', async () => { + const workspace = await models.workspace.create(); + const settings = await models.settings.create(); + const request = Object.assign(models.request.init(), { + _id: 'req_123', + parentId: workspace._id, + headers: [{name: 'Content-Type', value: CONTENT_TYPE_FORM_URLENCODED}], + method: 'POST', + body: { + mimeType: CONTENT_TYPE_FORM_URLENCODED, + params: [ + {name: 'foo', value: 'bar'}, + {name: 'bar', value: ''}, + {name: '', value: 'value'} + ] + }, + url: 'http://localhost' + }); + + const renderedRequest = await getRenderedRequest(request); + const response = await networkUtils._actuallySend( + renderedRequest, + workspace, + settings + ); + + const body = JSON.parse(Buffer.from(response.body, 'base64')); + expect(body).toEqual({ + options: { + CUSTOMREQUEST: 'POST', + ACCEPT_ENCODING: '', + NOBODY: 0, + FOLLOWLOCATION: true, + HTTPHEADER: [ + 'Content-Type: application/x-www-form-urlencoded', + 'Expect: ', + 'Transfer-Encoding: ' + ], + NOPROGRESS: false, + POSTFIELDS: 'foo=bar&bar=&=value', + PROXY: '', + TIMEOUT_MS: 0, + URL: 'http://localhost/', + USERAGENT: `insomnia/${getAppVersion()}`, + VERBOSE: true + } + }); + }); + it('skips sending and storing cookies with setting', async () => { const workspace = await models.workspace.create(); const settings = await models.settings.create(); diff --git a/app/network/network.js b/app/network/network.js index 59b880077..af70a61f3 100644 --- a/app/network/network.js +++ b/app/network/network.js @@ -297,7 +297,7 @@ export function _actuallySend (renderedRequest, workspace, settings) { let noBody = false; const expectsBody = ['POST', 'PUT', 'PATCH'].includes(renderedRequest.method.toUpperCase()); if (renderedRequest.body.mimeType === CONTENT_TYPE_FORM_URLENCODED) { - const d = querystring.buildFromParams(renderedRequest.body.params || [], true); + const d = querystring.buildFromParams(renderedRequest.body.params || [], false); setOpt(Curl.option.POSTFIELDS, d); // Send raw data } else if (renderedRequest.body.mimeType === CONTENT_TYPE_FORM_DATA) { const data = renderedRequest.body.params.map(param => {