Fix unix domain socket match

This commit is contained in:
Gregory Schier 2017-06-30 09:00:00 -07:00
parent de610f419b
commit 61fab44b04
2 changed files with 35 additions and 1 deletions

View File

@ -367,4 +367,38 @@ describe('actuallySend()', () => {
}
});
});
it('uses works with "unix" host', 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,
url: 'http://unix:3000/my/path',
method: 'GET'
});
const renderedRequest = await getRenderedRequest(request);
const {bodyBuffer} = await networkUtils._actuallySend(renderedRequest, workspace, settings);
// console.log('HELLO', response);
const body = JSON.parse(bodyBuffer);
expect(body).toEqual({
options: {
CUSTOMREQUEST: 'GET',
ACCEPT_ENCODING: '',
COOKIEFILE: '',
FOLLOWLOCATION: true,
HTTPHEADER: ['content-type: '],
NOPROGRESS: false,
PROXY: '',
NOBODY: 0,
TIMEOUT_MS: 0,
URL: 'http://unix:3000/my/path',
USERAGENT: `insomnia/${getAppVersion()}`,
VERBOSE: true
}
});
});
});

View File

@ -162,7 +162,7 @@ export function _actuallySend (renderedRequest, workspace, settings) {
// Set the URL, including the query parameters
const qs = querystring.buildFromParams(renderedRequest.parameters);
const url = querystring.joinUrl(renderedRequest.url, qs);
const isUnixSocket = url.match(/https?:\/\/unix:/);
const isUnixSocket = url.match(/https?:\/\/unix:\//);
const finalUrl = util.prepareUrlForSending(url, renderedRequest.settingEncodeUrl);
if (isUnixSocket) {
// URL prep will convert "unix:/path" hostname to "unix/path"