| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent bac9344 commit 9d59aa8
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -31,7 +31,7 @@ function onRequest(request, response) { | |||
| 31 | 31 | })); | |
| 32 | 32 | } | |
| 33 | 33 | ||
| 34 | - function onSession(session) { | ||
| 34 | + function onSession(session, next) { | ||
| 35 | 35 | const headers = { | |
| 36 | 36 | ':path': '/', | |
| 37 | 37 | ':method': 'GET', | |
@@ -54,6 +54,10 @@ function onSession(session) { | |||
| 54 | 54 | ||
| 55 | 55 | session.close(); | |
| 56 | 56 | this.cleanup(); | |
| 57 | + | ||
| 58 | + if (typeof next === 'function') { | ||
| 59 | + next(); | ||
| 60 | + } | ||
| 57 | 61 | })); | |
| 58 | 62 | request.end(); | |
| 59 | 63 | } | |
@@ -126,22 +130,31 @@ function onSession(session) { | |||
| 126 | 130 | connect( | |
| 127 | 131 | origin, | |
| 128 | 132 | clientOptions, | |
| 129 | - common.mustCall(onSession.bind({ cleanup, server })) | ||
| 133 | + common.mustCall(function(session) { | ||
| 134 | + onSession.call({ cleanup, server }, | ||
| 135 | + session, | ||
| 136 | + common.mustCall(testNoTls)); | ||
| 137 | + }) | ||
| 130 | 138 | ); | |
| 131 | 139 | ||
| 132 | - // HTTP/1.1 client | ||
| 133 | - get(Object.assign(parse(origin), clientOptions), common.mustNotCall()) | ||
| 134 | - .on('error', common.mustCall(cleanup)) | ||
| 135 | - .end(); | ||
| 136 | - | ||
| 137 | - // Incompatible ALPN TLS client | ||
| 138 | - let text = ''; | ||
| 139 | - tls(Object.assign({ port, ALPNProtocols: ['fake'] }, clientOptions)) | ||
| 140 | - .setEncoding('utf8') | ||
| 141 | - .on('data', (chunk) => text += chunk) | ||
| 142 | - .on('end', common.mustCall(() => { | ||
| 143 | - ok(/Unknown ALPN Protocol, expected `h2` to be available/.test(text)); | ||
| 144 | - cleanup(); | ||
| 145 | - })); | ||
| 140 | + function testNoTls() { | ||
| 141 | + // HTTP/1.1 client | ||
| 142 | + get(Object.assign(parse(origin), clientOptions), common.mustNotCall) | ||
| 143 | + .on('error', common.mustCall(cleanup)) | ||
| 144 | + .on('error', common.mustCall(testWrongALPN)) | ||
| 145 | + .end(); | ||
| 146 | + } | ||
| 147 | + | ||
| 148 | + function testWrongALPN() { | ||
| 149 | + // Incompatible ALPN TLS client | ||
| 150 | + let text = ''; | ||
| 151 | + tls(Object.assign({ port, ALPNProtocols: ['fake'] }, clientOptions)) | ||
| 152 | + .setEncoding('utf8') | ||
| 153 | + .on('data', (chunk) => text += chunk) | ||
| 154 | + .on('end', common.mustCall(() => { | ||
| 155 | + ok(/Unknown ALPN Protocol, expected `h2` to be available/.test(text)); | ||
| 156 | + cleanup(); | ||
| 157 | + })); | ||
| 158 | + } | ||
| 146 | 159 | })); | |
| 147 | 160 | } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments