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: #31224
Reviewed-By: Ruben Bridgewater <[email protected]>
Reviewed-By: Sam Roberts <[email protected]>
Reviewed-By: Richard Lau <[email protected]>
Reviewed-By: Beth Griggs <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
  • Loading branch information
andrewhughes101 authored and MylesBorins committed Jan 16, 2020
1 parent f93095d commit 220ea0c
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions doc/api/http.md
Original file line number Diff line number Diff line change
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 220ea0c

Please sign in to comment.