MCPcopy Create free account
hub / github.com/nodejs/node / onConnect

Function onConnect

test/parallel/test-tls-over-http-tunnel.js:128–171  ·  view source on GitHub ↗
(res, socket, header)

Source from the content-addressed store, hash-verified

126 }
127
128 function onConnect(res, socket, header) {
129 assert.strictEqual(res.statusCode, 200);
130 console.log('CLIENT: got CONNECT response');
131
132 // detach the socket
133 socket.removeAllListeners('data');
134 socket.removeAllListeners('close');
135 socket.removeAllListeners('error');
136 socket.removeAllListeners('drain');
137 socket.removeAllListeners('end');
138 socket.ondata = null;
139 socket.onend = null;
140 socket.ondrain = null;
141
142 console.log('CLIENT: Making HTTPS request');
143
144 https.get({
145 path: '/foo',
146 key: key,
147 cert: cert,
148 socket: socket, // reuse the socket
149 agent: false,
150 rejectUnauthorized: false
151 }, common.mustCall((res) => {
152 assert.strictEqual(res.statusCode, 200);
153
154 res.on('data', common.mustCall((chunk) => {
155 assert.strictEqual(chunk.toString(), 'hello world\n');
156 console.log('CLIENT: got HTTPS response');
157 gotRequest = true;
158 }));
159
160 res.on('end', common.mustCall(() => {
161 proxy.close();
162 server.close();
163 }));
164 })).on('error', (er) => {
165 // We're ok with getting ECONNRESET in this test, but it's
166 // timing-dependent, and thus unreliable. Any other errors
167 // are just failures, though.
168 if (er.code !== 'ECONNRESET')
169 throw er;
170 }).end();
171 }
172}));
173
174process.on('exit', () => {

Callers 2

requestMethod · 0.85
onUpgradeFunction · 0.85

Calls 7

getMethod · 0.65
closeMethod · 0.65
logMethod · 0.45
removeAllListenersMethod · 0.45
endMethod · 0.45
onMethod · 0.45
toStringMethod · 0.45

Tested by

no test coverage detected