mirror of
https://github.com/Kong/insomnia
synced 2024-11-08 06:39:48 +00:00
Always have equals signs in x-www-form-urlencoded bodies (#265)
This commit is contained in:
parent
70a9da1812
commit
b820af8e54
@ -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();
|
||||
|
@ -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 => {
|
||||
|
Loading…
Reference in New Issue
Block a user