After calling http(s).request only with options the method and path are changed to wrong value.
I've written simple example.
- VSCode Version: 1.38.1
- OS Version: Ubuntu 19.04 and Windows 10 1903
Steps to Reproduce:
- Run this code.
const https = require('https');
const Url = require('url');
const applyUrlToOptions = (options, url) => {
options.host = url.host;
options.origin = url.origin;
options.searchParams = url.searchParams;
options.protocol = url.protocol;
options.hostname = url.hostname;
options.hash = url.hash;
options.search = url.search;
options.pathname = url.pathname;
options.path = `${url.pathname}${url.search || ''}`;
options.href = url.href;
if (url.port !== '') {
options.port = Number(url.port);
}
if (url.username || url.password) {
options.auth = `${url.username}:${url.password}`;
options.username = url.username;
options.password = url.password;
}
return options;
};
const testProxyResolver = (method, url, options) => {
const uri = {};
const parsedUri = new Url.URL(url);
applyUrlToOptions(uri, parsedUri);
uri.method = method.toUpperCase();
uri.headers = options.headers || {};
uri.headers.host = uri.host;
uri.headers['content-type'] = 'application/json';
uri.headers['content-length'] = options.payload.length;
return https.request(uri);
};
const data = testProxyResolver('POST', 'https://example.com', {payload: 'payload'});
data.agent = undefined; // to reduce output
console.log(JSON.stringify(data, null, 2));
- In the console output will be the correct result of https.request
{
"_events": {},
"_eventsCount": 1,
"output": [],
"outputEncodings": [],
"outputCallbacks": [],
"outputSize": 0,
"writable": true,
"_last": true,
"chunkedEncoding": false,
"shouldKeepAlive": false,
"useChunkedEncodingByDefault": true,
"sendDate": false,
"_removedConnection": false,
"_removedContLen": false,
"_removedTE": false,
"_contentLength": null,
"_hasBody": true,
"_trailer": "",
"finished": false,
"_headerSent": false,
"socket": null,
"connection": null,
"_header": null,
"method": "POST",
"path": "/",
"_ended": false,
"res": null,
"timeoutCb": null,
"upgradeOrConnect": false,
"parser": null,
"maxHeadersCount": null
}
- Run the code above into vscode extension by the command from the palette
- The result will be wrong. Method and useChunkedEncodingByDefault properties are different.
{
"_events": {},
"_eventsCount": 1,
"output": [],
"outputEncodings": [],
"outputCallbacks": [],
"outputSize": 0,
"writable": true,
"_last": true,
"chunkedEncoding": false,
"shouldKeepAlive": false,
"useChunkedEncodingByDefault": false,
"sendDate": false,
"_removedConnection": false,
"_removedContLen": false,
"_removedTE": false,
"_contentLength": null,
"_hasBody": true,
"_trailer": "",
"finished": false,
"_headerSent": false,
"socket": null,
"connection": null,
"_header": null,
"method": "GET",
"path": "/",
"_ended": false,
"res": null,
"timeoutCb": null,
"upgradeOrConnect": false,
"parser": null,
"maxHeadersCount": null
}
It seems like the error somewhere here:
https://github.com/microsoft/vscode/blame/d3eb24828e2d977e4f3ac16ff1a332a020028464/src/vs/workbench/services/extensions/node/proxyResolver.ts#L331
It seems like in the URL always is searchParams, and condition for URL will be forever false
Also, you can execute this function in the example project (attached file)
- Run in the folder with an example project to execute native https.request
- Run the extension and choose command in palette
This issue occurs when all extensions are disabled
proxyresolver.zip
After calling http(s).request only with options the method and path are changed to wrong value.
I've written simple example.
Steps to Reproduce:
It seems like the error somewhere here:
https://github.com/microsoft/vscode/blame/d3eb24828e2d977e4f3ac16ff1a332a020028464/src/vs/workbench/services/extensions/node/proxyResolver.ts#L331
It seems like in the URL always is searchParams, and condition for URL will be forever false
Also, you can execute this function in the example project (attached file)
This issue occurs when all extensions are disabled
proxyresolver.zip