diff options
author | Anna Henningsen <anna@addaleax.net> | 2018-02-25 21:54:18 +0100 |
---|---|---|
committer | Matteo Collina <hello@matteocollina.com> | 2018-03-02 10:00:11 +0100 |
commit | d1bc6f0780c272cfea520c5df66fc4edb7122841 (patch) | |
tree | ec3a4162f509a6a49008279bd5953c26d86b1b57 /test | |
parent | bad41671183ab7ccdd86158efb75f0e47bb50da3 (diff) | |
download | android-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')
-rw-r--r-- | test/parallel/test-http2-https-fallback.js | 13 |
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(); + })); })); } |