MCPcopy Index your code
hub / github.com/nodejs/node / onSession

Function onSession

test/parallel/test-http2-https-fallback.js:35–64  ·  view source on GitHub ↗
(session, next)

Source from the content-addressed store, hash-verified

33}
34
35function onSession(session, next) {
36 const headers = {
37 ':path': '/',
38 ':method': 'GET',
39 ':scheme': 'https',
40 ':authority': `localhost:${this.server.address().port}`
41 };
42
43 const request = session.request(headers);
44 request.on('response', common.mustCall((headers) => {
45 assert.strictEqual(headers[':status'], 200);
46 assert.strictEqual(headers['content-type'], 'application/json');
47 }));
48 request.setEncoding('utf8');
49 let raw = '';
50 request.on('data', (chunk) => { raw += chunk; });
51 request.on('end', common.mustCall(() => {
52 const { alpnProtocol, httpVersion } = JSON.parse(raw);
53 assert.strictEqual(alpnProtocol, 'h2');
54 assert.strictEqual(httpVersion, '2.0');
55
56 session.close();
57 this.cleanup();
58
59 if (typeof next === 'function') {
60 next();
61 }
62 }));
63 request.end();
64}
65
66// HTTP/2 & HTTP/1.1 server
67{

Callers

nothing calls this directly

Calls 9

nextFunction · 0.70
addressMethod · 0.65
requestMethod · 0.65
parseMethod · 0.65
closeMethod · 0.65
onMethod · 0.45
setEncodingMethod · 0.45
cleanupMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…