summaryrefslogtreecommitdiff
path: root/test/parallel/test-http2-https-fallback.js
diff options
context:
space:
mode:
authorAnna Henningsen <anna@addaleax.net>2018-02-25 21:54:18 +0100
committerMatteo Collina <hello@matteocollina.com>2018-03-02 10:00:11 +0100
commitd1bc6f0780c272cfea520c5df66fc4edb7122841 (patch)
treeec3a4162f509a6a49008279bd5953c26d86b1b57 /test/parallel/test-http2-https-fallback.js
parentbad41671183ab7ccdd86158efb75f0e47bb50da3 (diff)
downloadandroid-node-v8-d1bc6f0780c272cfea520c5df66fc4edb7122841.tar.gz
android-node-v8-d1bc6f0780c272cfea520c5df66fc4edb7122841.tar.bz2
android-node-v8-d1bc6f0780c272cfea520c5df66fc4edb7122841.zip
http2: send error text in case of ALPN mismatch
Send a human-readable HTTP/1 response in case of an unexpected ALPN protocol. This helps with debugging this condition, since previously the only result of it would be a closed socket. PR-URL: https://github.com/nodejs/node/pull/18986 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Diffstat (limited to 'test/parallel/test-http2-https-fallback.js')
-rw-r--r--test/parallel/test-http2-https-fallback.js13
1 files changed, 10 insertions, 3 deletions
diff --git a/test/parallel/test-http2-https-fallback.js b/test/parallel/test-http2-https-fallback.js
index 01b694e586..5d9a7e1710 100644
--- a/test/parallel/test-http2-https-fallback.js
+++ b/test/parallel/test-http2-https-fallback.js
@@ -6,7 +6,7 @@ const fixtures = require('../common/fixtures');
if (!common.hasCrypto)
common.skip('missing crypto');
-const { strictEqual } = require('assert');
+const { strictEqual, ok } = require('assert');
const { createSecureContext } = require('tls');
const { createSecureServer, connect } = require('http2');
const { get } = require('https');
@@ -131,10 +131,17 @@ function onSession(session) {
// HTTP/1.1 client
get(Object.assign(parse(origin), clientOptions), common.mustNotCall())
- .on('error', common.mustCall(cleanup));
+ .on('error', common.mustCall(cleanup))
+ .end();
// Incompatible ALPN TLS client
+ let text = '';
tls(Object.assign({ port, ALPNProtocols: ['fake'] }, clientOptions))
- .on('error', common.mustCall(cleanup));
+ .setEncoding('utf8')
+ .on('data', (chunk) => text += chunk)
+ .on('end', common.mustCall(() => {
+ ok(/Unknown ALPN Protocol, expected `h2` to be available/.test(text));
+ cleanup();
+ }));
}));
}