fix: grid connection invalid method (#17706)

This patch fixes invalid method (GET instead of POST) used when
connecting to Selenium Grid by http with proxy.

Fixes #17707
This commit is contained in:
wodyjowski 2022-09-30 09:41:03 +02:00 committed by GitHub
parent f1f4af2f7d
commit 33bbb15e30
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -50,15 +50,16 @@ export function httpRequest(params: HTTPRequestParams, onResponse: (r: http.Inco
const proxyURL = getProxyForUrl(params.url); const proxyURL = getProxyForUrl(params.url);
if (proxyURL) { if (proxyURL) {
const parsedProxyURL = URL.parse(proxyURL);
if (params.url.startsWith('http:')) { if (params.url.startsWith('http:')) {
const proxy = URL.parse(proxyURL);
options = { options = {
path: parsedUrl.href, path: parsedUrl.href,
host: proxy.hostname, host: parsedProxyURL.hostname,
port: proxy.port, port: parsedProxyURL.port,
headers: options.headers,
method: options.method
}; };
} else { } else {
const parsedProxyURL = URL.parse(proxyURL);
(parsedProxyURL as any).secureProxy = parsedProxyURL.protocol === 'https:'; (parsedProxyURL as any).secureProxy = parsedProxyURL.protocol === 'https:';
options.agent = new HttpsProxyAgent(parsedProxyURL); options.agent = new HttpsProxyAgent(parsedProxyURL);