playwright-core 1.54.0 → 1.54.1-beta-1753117034000
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/server/utils/network.js +20 -33
- package/package.json +1 -1
|
@@ -41,12 +41,14 @@ module.exports = __toCommonJS(network_exports);
|
|
|
41
41
|
var import_http = __toESM(require("http"));
|
|
42
42
|
var import_http2 = __toESM(require("http2"));
|
|
43
43
|
var import_https = __toESM(require("https"));
|
|
44
|
+
var import_url = __toESM(require("url"));
|
|
44
45
|
var import_utilsBundle = require("../../utilsBundle");
|
|
45
46
|
var import_happyEyeballs = require("./happyEyeballs");
|
|
46
47
|
const NET_DEFAULT_TIMEOUT = 3e4;
|
|
47
48
|
function httpRequest(params, onResponse, onError) {
|
|
48
|
-
const parsedUrl =
|
|
49
|
-
|
|
49
|
+
const parsedUrl = import_url.default.parse(params.url);
|
|
50
|
+
let options = {
|
|
51
|
+
...parsedUrl,
|
|
50
52
|
agent: parsedUrl.protocol === "https:" ? import_happyEyeballs.httpsHappyEyeballsAgent : import_happyEyeballs.httpHappyEyeballsAgent,
|
|
51
53
|
method: params.method || "GET",
|
|
52
54
|
headers: params.headers
|
|
@@ -55,15 +57,18 @@ function httpRequest(params, onResponse, onError) {
|
|
|
55
57
|
options.rejectUnauthorized = params.rejectUnauthorized;
|
|
56
58
|
const proxyURL = (0, import_utilsBundle.getProxyForUrl)(params.url);
|
|
57
59
|
if (proxyURL) {
|
|
58
|
-
const parsedProxyURL =
|
|
60
|
+
const parsedProxyURL = import_url.default.parse(proxyURL);
|
|
59
61
|
if (params.url.startsWith("http:")) {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
+
options = {
|
|
63
|
+
path: parsedUrl.href,
|
|
64
|
+
host: parsedProxyURL.hostname,
|
|
65
|
+
port: parsedProxyURL.port,
|
|
66
|
+
headers: options.headers,
|
|
67
|
+
method: options.method
|
|
68
|
+
};
|
|
62
69
|
} else {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
secureProxy: parsedProxyURL.protocol === "https:"
|
|
66
|
-
});
|
|
70
|
+
parsedProxyURL.secureProxy = parsedProxyURL.protocol === "https:";
|
|
71
|
+
options.agent = new import_utilsBundle.HttpsProxyAgent(parsedProxyURL);
|
|
67
72
|
options.rejectUnauthorized = false;
|
|
68
73
|
}
|
|
69
74
|
}
|
|
@@ -77,7 +82,7 @@ function httpRequest(params, onResponse, onError) {
|
|
|
77
82
|
onResponse(res);
|
|
78
83
|
}
|
|
79
84
|
};
|
|
80
|
-
const request = options.protocol === "https:" ? import_https.default.request(
|
|
85
|
+
const request = options.protocol === "https:" ? import_https.default.request(options, requestCallback) : import_http.default.request(options, requestCallback);
|
|
81
86
|
request.on("error", onError);
|
|
82
87
|
if (params.socketTimeout !== void 0) {
|
|
83
88
|
request.setTimeout(params.socketTimeout, () => {
|
|
@@ -126,21 +131,19 @@ function createProxyAgent(proxy, forUrl) {
|
|
|
126
131
|
let proxyServer = proxy.server.trim();
|
|
127
132
|
if (!/^\w+:\/\//.test(proxyServer))
|
|
128
133
|
proxyServer = "http://" + proxyServer;
|
|
129
|
-
const proxyOpts =
|
|
134
|
+
const proxyOpts = import_url.default.parse(proxyServer);
|
|
130
135
|
if (proxyOpts.protocol?.startsWith("socks")) {
|
|
131
136
|
return new import_utilsBundle.SocksProxyAgent({
|
|
132
137
|
host: proxyOpts.hostname,
|
|
133
138
|
port: proxyOpts.port || void 0
|
|
134
139
|
});
|
|
135
140
|
}
|
|
136
|
-
if (proxy.username)
|
|
137
|
-
proxyOpts.
|
|
138
|
-
proxyOpts.password = proxy.password || "";
|
|
139
|
-
}
|
|
141
|
+
if (proxy.username)
|
|
142
|
+
proxyOpts.auth = `${proxy.username}:${proxy.password || ""}`;
|
|
140
143
|
if (forUrl && ["ws:", "wss:"].includes(forUrl.protocol)) {
|
|
141
|
-
return new import_utilsBundle.HttpsProxyAgent(
|
|
144
|
+
return new import_utilsBundle.HttpsProxyAgent(proxyOpts);
|
|
142
145
|
}
|
|
143
|
-
return new import_utilsBundle.HttpsProxyAgent(
|
|
146
|
+
return new import_utilsBundle.HttpsProxyAgent(proxyOpts);
|
|
144
147
|
}
|
|
145
148
|
function createHttpServer(...args) {
|
|
146
149
|
const server = import_http.default.createServer(...args);
|
|
@@ -200,22 +203,6 @@ function decorateServer(server) {
|
|
|
200
203
|
return close.call(server, callback);
|
|
201
204
|
};
|
|
202
205
|
}
|
|
203
|
-
function convertURLtoLegacyUrl(url2) {
|
|
204
|
-
return {
|
|
205
|
-
auth: url2.username ? url2.username + ":" + url2.password : null,
|
|
206
|
-
hash: url2.hash || null,
|
|
207
|
-
host: url2.hostname ? url2.hostname + ":" + url2.port : null,
|
|
208
|
-
hostname: url2.hostname || null,
|
|
209
|
-
href: url2.href,
|
|
210
|
-
path: url2.pathname + url2.search,
|
|
211
|
-
pathname: url2.pathname,
|
|
212
|
-
protocol: url2.protocol,
|
|
213
|
-
search: url2.search || null,
|
|
214
|
-
slashes: true,
|
|
215
|
-
port: url2.port || null,
|
|
216
|
-
query: url2.search.slice(1) || null
|
|
217
|
-
};
|
|
218
|
-
}
|
|
219
206
|
// Annotate the CommonJS export names for ESM import in node:
|
|
220
207
|
0 && (module.exports = {
|
|
221
208
|
NET_DEFAULT_TIMEOUT,
|