mirror of
https://github.com/microsoft/playwright.git
synced 2025-06-26 21:40:17 +00:00
test: fix WebKit socks proxy tests (#19035)
Fixes https://github.com/microsoft/playwright/issues/18301
This commit is contained in:
parent
30debb5110
commit
b84a7a9e57
@ -49,9 +49,11 @@ export const serverFixtures: Fixtures<ServerFixtures, ServerWorkerOptions> = {
|
|||||||
|
|
||||||
const socksServer = socks.createServer((info, accept, deny) => {
|
const socksServer = socks.createServer((info, accept, deny) => {
|
||||||
const socket = accept(true);
|
const socket = accept(true);
|
||||||
if (socket) {
|
if (!socket)
|
||||||
// Catch and ignore ECONNRESET errors.
|
return;
|
||||||
socket.on('error', () => {});
|
socket.on('data', data => {
|
||||||
|
if (!data.toString().includes('\r\n\r\n'))
|
||||||
|
return;
|
||||||
const body = '<html><title>Served by the SOCKS proxy</title></html>';
|
const body = '<html><title>Served by the SOCKS proxy</title></html>';
|
||||||
socket.end([
|
socket.end([
|
||||||
'HTTP/1.1 200 OK',
|
'HTTP/1.1 200 OK',
|
||||||
@ -61,7 +63,10 @@ export const serverFixtures: Fixtures<ServerFixtures, ServerWorkerOptions> = {
|
|||||||
'',
|
'',
|
||||||
body
|
body
|
||||||
].join('\r\n'));
|
].join('\r\n'));
|
||||||
}
|
});
|
||||||
|
// Catch and ignore ECONNRESET errors.
|
||||||
|
socket.on('error', () => {});
|
||||||
|
setTimeout(() => socket.end(), 1000);
|
||||||
});
|
});
|
||||||
const socksPort = port + 2;
|
const socksPort = port + 2;
|
||||||
socksServer.listen(socksPort, 'localhost');
|
socksServer.listen(socksPort, 'localhost');
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user