Skip to content

Commit

Permalink
doc: prefer server vs srv and client vs clt
Browse files Browse the repository at this point in the history
PR-URL: nodejs#31224
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Beth Griggs <Bethany.Griggs@uk.ibm.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
  • Loading branch information
andrewhughes101 authored and Trott committed Jan 9, 2020
1 parent f2a089a commit 41dd175
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions doc/api/http.md
Expand Up @@ -374,16 +374,16 @@ const proxy = http.createServer((req, res) => {
res.writeHead(200, { 'Content-Type': 'text/plain' });
res.end('okay');
});
proxy.on('connect', (req, cltSocket, head) => {
proxy.on('connect', (req, clientSocket, head) => {
// Connect to an origin server
const { port, hostname } = new URL(`http://${req.url}`);
const srvSocket = net.connect(port || 80, hostname, () => {
cltSocket.write('HTTP/1.1 200 Connection Established\r\n' +
const serverSocket = net.connect(port || 80, hostname, () => {
clientSocket.write('HTTP/1.1 200 Connection Established\r\n' +
'Proxy-agent: Node.js-Proxy\r\n' +
'\r\n');
srvSocket.write(head);
srvSocket.pipe(cltSocket);
cltSocket.pipe(srvSocket);
serverSocket.write(head);
serverSocket.pipe(clientSocket);
clientSocket.pipe(serverSocket);
});
});

Expand Down Expand Up @@ -525,11 +525,11 @@ A client server pair demonstrating how to listen for the `'upgrade'` event.
const http = require('http');

// Create an HTTP server
const srv = http.createServer((req, res) => {
const server = http.createServer((req, res) => {
res.writeHead(200, { 'Content-Type': 'text/plain' });
res.end('okay');
});
srv.on('upgrade', (req, socket, head) => {
server.on('upgrade', (req, socket, head) => {
socket.write('HTTP/1.1 101 Web Socket Protocol Handshake\r\n' +
'Upgrade: WebSocket\r\n' +
'Connection: Upgrade\r\n' +
Expand All @@ -539,7 +539,7 @@ srv.on('upgrade', (req, socket, head) => {
});

// Now that server is running
srv.listen(1337, '127.0.0.1', () => {
server.listen(1337, '127.0.0.1', () => {

// make a request
const options = {
Expand Down

0 comments on commit 41dd175

Please sign in to comment.