11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_ci// Flags: --expose-internals 31cb0ef41Sopenharmony_ci 41cb0ef41Sopenharmony_ciconst common = require('../common'); 51cb0ef41Sopenharmony_ciif (!common.hasCrypto) 61cb0ef41Sopenharmony_ci common.skip('missing crypto'); 71cb0ef41Sopenharmony_ci 81cb0ef41Sopenharmony_ciconst assert = require('assert'); 91cb0ef41Sopenharmony_ciconst http = require('http'); 101cb0ef41Sopenharmony_ciconst http2 = require('http2'); 111cb0ef41Sopenharmony_ciconst { NghttpError } = require('internal/http2/util'); 121cb0ef41Sopenharmony_ci 131cb0ef41Sopenharmony_ci// Creating an http1 server here... 141cb0ef41Sopenharmony_ciconst server = http.createServer(common.mustNotCall()) 151cb0ef41Sopenharmony_ci .on('clientError', common.mustCall((error, socket) => { 161cb0ef41Sopenharmony_ci assert.strictEqual(error.code, 'HPE_PAUSED_H2_UPGRADE'); 171cb0ef41Sopenharmony_ci assert.strictEqual(error.bytesParsed, 24); 181cb0ef41Sopenharmony_ci socket.write('HTTP/1.1 400 No H2 support\r\n\r\n'); 191cb0ef41Sopenharmony_ci 201cb0ef41Sopenharmony_ci // Don't give client a chance to send a preamble. 211cb0ef41Sopenharmony_ci socket.destroy(); 221cb0ef41Sopenharmony_ci })); 231cb0ef41Sopenharmony_ci 241cb0ef41Sopenharmony_ciserver.listen(0, common.mustCall(() => { 251cb0ef41Sopenharmony_ci const client = http2.connect(`http://localhost:${server.address().port}`); 261cb0ef41Sopenharmony_ci 271cb0ef41Sopenharmony_ci const req = client.request(); 281cb0ef41Sopenharmony_ci req.on('close', common.mustCall()); 291cb0ef41Sopenharmony_ci 301cb0ef41Sopenharmony_ci req.on('error', common.expectsError({ 311cb0ef41Sopenharmony_ci code: 'ERR_HTTP2_ERROR', 321cb0ef41Sopenharmony_ci constructor: NghttpError, 331cb0ef41Sopenharmony_ci message: 'Protocol error' 341cb0ef41Sopenharmony_ci })); 351cb0ef41Sopenharmony_ci 361cb0ef41Sopenharmony_ci client.on('error', common.expectsError({ 371cb0ef41Sopenharmony_ci code: 'ERR_HTTP2_ERROR', 381cb0ef41Sopenharmony_ci constructor: NghttpError, 391cb0ef41Sopenharmony_ci name: 'Error', 401cb0ef41Sopenharmony_ci message: 'Protocol error' 411cb0ef41Sopenharmony_ci })); 421cb0ef41Sopenharmony_ci 431cb0ef41Sopenharmony_ci client.on('close', common.mustCall(() => server.close())); 441cb0ef41Sopenharmony_ci})); 45