@@ -374,16 +374,16 @@ const proxy = http.createServer((req, res) => { |
374 | 374 | res.writeHead(200, { 'Content-Type': 'text/plain' }); |
375 | 375 | res.end('okay'); |
376 | 376 | }); |
377 | | -proxy.on('connect', (req, cltSocket, head) => { |
| 377 | +proxy.on('connect', (req, clientSocket, head) => { |
378 | 378 | // Connect to an origin server |
379 | 379 | const { port, hostname } = new URL(`http://${req.url}`); |
380 | | - const srvSocket = net.connect(port || 80, hostname, () => { |
381 | | - cltSocket.write('HTTP/1.1 200 Connection Established\r\n' + |
| 380 | + const serverSocket = net.connect(port || 80, hostname, () => { |
| 381 | + clientSocket.write('HTTP/1.1 200 Connection Established\r\n' + |
382 | 382 | 'Proxy-agent: Node.js-Proxy\r\n' + |
383 | 383 | '\r\n'); |
384 | | - srvSocket.write(head); |
385 | | - srvSocket.pipe(cltSocket); |
386 | | - cltSocket.pipe(srvSocket); |
| 384 | + serverSocket.write(head); |
| 385 | + serverSocket.pipe(clientSocket); |
| 386 | + clientSocket.pipe(serverSocket); |
387 | 387 | }); |
388 | 388 | }); |
389 | 389 |
|
@@ -525,11 +525,11 @@ A client server pair demonstrating how to listen for the `'upgrade'` event. |
525 | 525 | const http = require('http'); |
526 | 526 |
|
527 | 527 | // Create an HTTP server |
528 | | -const srv = http.createServer((req, res) => { |
| 528 | +const server = http.createServer((req, res) => { |
529 | 529 | res.writeHead(200, { 'Content-Type': 'text/plain' }); |
530 | 530 | res.end('okay'); |
531 | 531 | }); |
532 | | -srv.on('upgrade', (req, socket, head) => { |
| 532 | +server.on('upgrade', (req, socket, head) => { |
533 | 533 | socket.write('HTTP/1.1 101 Web Socket Protocol Handshake\r\n' + |
534 | 534 | 'Upgrade: WebSocket\r\n' + |
535 | 535 | 'Connection: Upgrade\r\n' + |
@@ -539,7 +539,7 @@ srv.on('upgrade', (req, socket, head) => { |
539 | 539 | }); |
540 | 540 |
|
541 | 541 | // Now that server is running |
542 | | -srv.listen(1337, '127.0.0.1', () => { |
| 542 | +server.listen(1337, '127.0.0.1', () => { |
543 | 543 |
|
544 | 544 | // make a request |
545 | 545 | const options = { |
|