Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 220ea0c

Browse filesBrowse files
andrewhughes101MylesBorins
authored andcommitted
doc: prefer server vs srv and client vs clt
PR-URL: #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>
1 parent f93095d commit 220ea0c
Copy full SHA for 220ea0c

File tree

Expand file treeCollapse file tree

1 file changed

+9
-9
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+9
-9
lines changed
Open diff view settings
Collapse file

‎doc/api/http.md‎

Copy file name to clipboardExpand all lines: doc/api/http.md
+9-9Lines changed: 9 additions & 9 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -374,16 +374,16 @@ const proxy = http.createServer((req, res) => {
374374
res.writeHead(200, { 'Content-Type': 'text/plain' });
375375
res.end('okay');
376376
});
377-
proxy.on('connect', (req, cltSocket, head) => {
377+
proxy.on('connect', (req, clientSocket, head) => {
378378
// Connect to an origin server
379379
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' +
382382
'Proxy-agent: Node.js-Proxy\r\n' +
383383
'\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);
387387
});
388388
});
389389

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

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

541541
// Now that server is running
542-
srv.listen(1337, '127.0.0.1', () => {
542+
server.listen(1337, '127.0.0.1', () => {
543543

544544
// make a request
545545
const options = {

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.